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 |
|---|---|---|---|---|
cfixed_string.rs | use std::borrow::{Borrow, Cow};
use std::ffi::{CStr, CString};
use std::fmt;
use std::mem;
use std::ops;
use std::os::raw::c_char;
use std::ptr;
const STRING_SIZE: usize = 512;
/// This is a C String abstractions that presents a CStr like
/// interface for interop purposes but tries to be little nicer
/// by avoiding... | (&self) -> &CStr {
use std::slice;
match *self {
CFixedString::Local { ref s, len } => unsafe {
mem::transmute(slice::from_raw_parts(s.as_ptr(), len + 1))
},
CFixedString::Heap { ref s,.. } => s,
}
}
}
impl Borrow<CStr> for CFixedString {... | deref | identifier_name |
cfixed_string.rs | use std::borrow::{Borrow, Cow};
use std::ffi::{CStr, CString};
use std::fmt;
use std::mem;
use std::ops;
use std::os::raw::c_char;
use std::ptr;
const STRING_SIZE: usize = 512;
/// This is a C String abstractions that presents a CStr like
/// interface for interop purposes but tries to be little nicer
/// by avoiding... |
/// Converts a `CFixedString` into a `Cow<str>`.
///
/// This function will calculate the length of this string (which normally
/// requires a linear amount of work to be done) and then return the
/// resulting slice as a `Cow<str>`, replacing any invalid UTF-8 sequences
/// with `U+FFFD REPLA... | {
match *self {
CFixedString::Local { .. } => false,
_ => true,
}
} | identifier_body |
cfixed_string.rs | use std::borrow::{Borrow, Cow};
use std::ffi::{CStr, CString};
use std::fmt;
use std::mem;
use std::ops;
use std::os::raw::c_char;
use std::ptr;
const STRING_SIZE: usize = 512;
/// This is a C String abstractions that presents a CStr like
/// interface for interop purposes but tries to be little nicer
/// by avoiding... | /// used with write! or the `fmt::Write` trait
pub fn new() -> Self {
unsafe {
CFixedString::Local {
s: mem::uninitialized(),
len: 0,
}
}
}
pub fn from_str<S: AsRef<str>>(s: S) -> Self {
Self::from(s.as_ref())
}
pu... | }
impl CFixedString {
/// Creates an empty CFixedString, this is intended to be | random_line_split |
generics.rs | #![recursion_limit = "128"]
#[macro_use]
extern crate generic_array;
use generic_array::typenum::consts::U4;
use std::fmt::Debug;
use std::ops::Add;
use generic_array::{GenericArray, ArrayLength};
use generic_array::sequence::*;
use generic_array::functional::*;
/// Example function using generics to pass N-length... |
pub fn generic_array_same_type_variable_length_zip_sum<T, N>(a: GenericArray<T, N>, b: GenericArray<T, N>) -> i32
where
N: ArrayLength<T> + ArrayLength<<T as Add<T>>::Output>,
T: Add<T, Output=i32>,
{
a.zip(b, |l, r| l + r).map(|x| x + 1).fold(0, |a, x| x + a)
}
/// Complex example using fully generic `G... | {
a.zip(b, |l, r| l + r).map(|x| x + 1).fold(0, |a, x| x + a)
} | identifier_body |
generics.rs | #![recursion_limit = "128"]
#[macro_use]
extern crate generic_array;
use generic_array::typenum::consts::U4;
use std::fmt::Debug;
use std::ops::Add;
use generic_array::{GenericArray, ArrayLength};
use generic_array::sequence::*;
use generic_array::functional::*;
/// Example function using generics to pass N-length... | <A, B, N: ArrayLength<A> + ArrayLength<B>>(a: GenericArray<A, N>, b: GenericArray<B, N>) -> i32
where
A: Add<B>,
N: ArrayLength<<A as Add<B>>::Output> +
ArrayLength<<<A as Add<B>>::Output as Add<i32>>::Output>,
<A as Add<B>>::Output: Add<i32>,
<<A as Add<B>>::Output as Add<i32>>::Output: Add<i32... | generic_array_zip_sum | identifier_name |
generics.rs | #![recursion_limit = "128"]
#[macro_use]
extern crate generic_array;
use generic_array::typenum::consts::U4;
use std::fmt::Debug;
use std::ops::Add;
use generic_array::{GenericArray, ArrayLength};
use generic_array::sequence::*;
use generic_array::functional::*;
/// Example function using generics to pass N-length... | println!("{:?}", c);
c.fold(0, |a, x| x + a)
}
/// Super-simple fixed-length i32 `GenericArray`s
pub fn generic_array_plain_zip_sum(a: GenericArray<i32, U4>, b: GenericArray<i32, U4>) -> i32 {
a.zip(b, |l, r| l + r).map(|x| x + 1).fold(0, |a, x| x + a)
}
pub fn generic_array_variable_length_zip_sum<N>(a:... | SequenceItem<MappedSequence<MappedSequence<A, i32, i32>, i32, i32>>: Add<i32, Output=i32> // `x + a`, note the order
{
let c = a.zip(b, |l, r| l + r).map(|x| x + 1);
| random_line_split |
broker.rs | use std::option::Option;
use redis;
use rustc_serialize::json::ToJson;
use uuid::Uuid;
use task::{TaskDef, Task, TaskState};
| broker: &'a RedisBroker
}
impl<'a> Task for RedisTask<'a> {
fn status<'b>(&self) -> Option<&'b ToJson> {
None
}
fn await<'b>(&self) -> Option<&'b ToJson> {
None
}
fn get<'b>(&self) -> Option<&'b ToJson> {
None
}
}
pub struct RedisBroker {
conn: redis::Connec... |
pub struct RedisTask<'a> {
id: String,
state: TaskState, | random_line_split |
broker.rs | use std::option::Option;
use redis;
use rustc_serialize::json::ToJson;
use uuid::Uuid;
use task::{TaskDef, Task, TaskState};
pub struct RedisTask<'a> {
id: String,
state: TaskState,
broker: &'a RedisBroker
}
impl<'a> Task for RedisTask<'a> {
fn status<'b>(&self) -> Option<&'b ToJson> {
No... | <'b>(&self) -> Option<&'b ToJson> {
None
}
fn get<'b>(&self) -> Option<&'b ToJson> {
None
}
}
pub struct RedisBroker {
conn: redis::Connection,
key_prefix: &'static str,
poll_interval_ms: u32
}
impl RedisBroker {
pub fn new(conn: redis::Connection) -> RedisBroker {
... | await | identifier_name |
render.rs | use gfx::{self, texture, Factory, Resources, PipelineState, Encoder, CommandBuffer};
use gfx::traits::FactoryExt;
use gfx::handle::{RenderTargetView, DepthStencilView};
use image::RgbaImage;
use resource::atlas::{Texmap, TextureSelection};
use std::collections::HashMap;
use ui::managed::ManagedBuffer;
use ColorFormat;... | (&mut self) -> &mut ManagedBuffer<R> {
&mut self.buffer
}
pub fn render<F, C>(&mut self, factory: &mut F, encoder: &mut Encoder<R, C>) where F: Factory<R> + FactoryExt<R>, C: CommandBuffer<R> {
self.buffer.update(factory, encoder);
self.data.buffer = self.buffer.remote().clone();
encoder.draw(&self.buffe... | buffer_mut | identifier_name |
render.rs | use gfx::{self, texture, Factory, Resources, PipelineState, Encoder, CommandBuffer};
use gfx::traits::FactoryExt;
use gfx::handle::{RenderTargetView, DepthStencilView};
use image::RgbaImage;
use resource::atlas::{Texmap, TextureSelection};
use std::collections::HashMap;
use ui::managed::ManagedBuffer;
use ColorFormat;... | for pipe in &mut self.textured {
pipe.buffer_mut().new_zone();
}
zone
}
pub fn extend_zone<I>(&mut self, iter: I, texture: Option<&str>) -> bool where I: IntoIterator<Item=Vertex> {
if let Some(texture) = texture {
if let Some(&(index, selection)) = self.textures.get(texture) {
//println!("tex:... | }
pub fn new_zone(&mut self) -> usize {
let zone = self.solid.buffer_mut().new_zone();
| random_line_split |
render.rs | use gfx::{self, texture, Factory, Resources, PipelineState, Encoder, CommandBuffer};
use gfx::traits::FactoryExt;
use gfx::handle::{RenderTargetView, DepthStencilView};
use image::RgbaImage;
use resource::atlas::{Texmap, TextureSelection};
use std::collections::HashMap;
use ui::managed::ManagedBuffer;
use ColorFormat;... | else {
false
}
} else {
self.solid.buffer_mut().extend(iter);
true
}
}
fn extend_textured<I>(pipe: &mut TexturedPipe<R>, iter: I, selection: TextureSelection) where I: IntoIterator<Item=Vertex> {
//println!("sel: {:?}", selection);
pipe.buffer_mut().extend(iter.into_iter().map(|v| {/*pr... | {
//println!("tex: {}@{}, ", texture, index);
Self::extend_textured(&mut self.textured[index], iter, selection);
true
} | conditional_block |
render.rs | use gfx::{self, texture, Factory, Resources, PipelineState, Encoder, CommandBuffer};
use gfx::traits::FactoryExt;
use gfx::handle::{RenderTargetView, DepthStencilView};
use image::RgbaImage;
use resource::atlas::{Texmap, TextureSelection};
use std::collections::HashMap;
use ui::managed::ManagedBuffer;
use ColorFormat;... |
pub fn render<F, C>(&mut self, factory: &mut F, encoder: &mut Encoder<R, C>) where F: Factory<R> + FactoryExt<R>, C: CommandBuffer<R> {
self.solid.render(factory, encoder);
for pipe in &mut self.textured {
pipe.render(factory, encoder);
}
}
}
gfx_defines!{
vertex Vertex {
pos: [f32; 3] = "... | {
let index = self.textured.len();
self.textured.push(TexturedPipe::create(factory, texture, self.out.clone(), self.out_depth.clone()));
for (k, v) in texmap.0.iter() {
self.textures.insert(k.clone(), (index, *v));
}
} | identifier_body |
text.rs | debug!("TextRunScanner: complete.");
InlineFragments {
fragments: new_fragments,
}
}
/// A "clump" is a range of inline flow leaves that can be merged together into a single
/// fragment. Adjacent text with the same style can be merged, and nothing else can.
///
/... |
_ => None
};
let (mut start_position, mut end_position) = (0, 0);
for (byte_index, character) in text.char_indices() {
// Search for the first font in this font group that contains a glyph for this
// character... | {
// `range` is the range within the current fragment. To get the range
// within the text run, offset it by the length of the preceding fragments.
Some(range.begin() + ByteIndex(run_info.text.len() as isize))
} | conditional_block |
text.rs | debug!("TextRunScanner: complete.");
InlineFragments {
fragments: new_fragments,
}
}
/// A "clump" is a range of inline flow leaves that can be merged together into a single
/// fragment. Adjacent text with the same style can be merged, and nothing else can.
///
... | }).collect::<Vec<_>>()
};
// Make new fragments with the runs and adjusted text indices.
debug!("TextRunScanner: pushing {} fragment(s)", self.clump.len());
let mut mappings = mappings.into_iter().peekable();
let mut prev_fragments_to_meld = Vec::new();
for ... | } | random_line_split |
text.rs | /// be adjusted.
fn flush_clump_to_list(&mut self,
font_context: &mut FontContext,
out_fragments: &mut Vec<Fragment>,
paragraph_bytes_processed: &mut usize,
bidi_levels: Option<&[u8]>,
... | it_first_fragment_at_newline_if_necessary(fr | identifier_name | |
borrowck-vec-pattern-loan-from-mut.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 ... | {} | identifier_body | |
borrowck-vec-pattern-loan-from-mut.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() {} | random_line_split | |
borrowck-vec-pattern-loan-from-mut.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 ... | () {}
| main | identifier_name |
mod.rs | //! The NFA we construct for each regex. Since the states are not
//! really of interest, we represent this just as a vector of labeled
//! edges.
use std::fmt::{Debug, Formatter, Error};
use std::usize;
use lexer::re::{Regex, Alternative, Elem, RepeatOp, Test};
#[cfg(test)]
mod interpret;
#[cfg(test)]
mod test;
#[... | (&mut self, elem: &Elem, accept: NFAStateIndex, reject: NFAStateIndex) -> NFAStateIndex {
match *elem {
Elem::Any => {
// [s0] -otherwise-> [accept]
let s0 = self.new_state(StateKind::Neither);
self.push_edge(s0, Other, accept);
s0
... | elem | identifier_name |
mod.rs | //! The NFA we construct for each regex. Since the states are not
//! really of interest, we represent this just as a vector of labeled
//! edges.
use std::fmt::{Debug, Formatter, Error};
use std::usize;
use lexer::re::{Regex, Alternative, Elem, RepeatOp, Test};
#[cfg(test)]
mod interpret;
#[cfg(test)]
mod test;
#[... |
let next_index = index + 1;
if next_index >= self.edges.len() || self.edges[next_index].from!= self.from {
self.index = usize::MAX;
} else {
self.index = next_index;
}
Some(&self.edges[index])
}
}
impl Debug for NFAStateIndex {
fn fmt(&self, fm... | {
return None;
} | conditional_block |
mod.rs | //! The NFA we construct for each regex. Since the states are not
//! really of interest, we represent this just as a vector of labeled
//! edges.
use std::fmt::{Debug, Formatter, Error};
use std::usize;
use lexer::re::{Regex, Alternative, Elem, RepeatOp, Test};
#[cfg(test)]
mod interpret;
#[cfg(test)]
mod test;
#[... |
fn first(state: &State) -> &usize { &state.first_other_edge }
}
impl EdgeLabel for Test {
fn vec_mut(nfa: &mut Edges) -> &mut Vec<Edge<Test>> { &mut nfa.test_edges }
fn first_mut(state: &mut State) -> &mut usize { &mut state.first_test_edge }
fn vec(nfa: &Edges) -> &Vec<Edge<Test>> { &nfa.test_edges }... | { &nfa.other_edges } | identifier_body |
mod.rs | //! The NFA we construct for each regex. Since the states are not
//! really of interest, we represent this just as a vector of labeled
//! edges.
use std::fmt::{Debug, Formatter, Error};
use std::usize;
use lexer::re::{Regex, Alternative, Elem, RepeatOp, Test};
#[cfg(test)]
mod interpret;
#[cfg(test)]
mod test;
#[... | let s0 = nfa.regex(regex, ACCEPT, REJECT);
nfa.push_edge(START, Noop, s0);
nfa
}
///////////////////////////////////////////////////////////////////////////
// Public methods for querying an NFA
pub fn edges<L:EdgeLabel>(&self, from: NFAStateIndex) -> EdgeIterator<L> {
... | pub fn from_re(regex: &Regex) -> NFA {
let mut nfa = NFA::new(); | random_line_split |
htmlbaseelement.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::HTMLBaseElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBaseEl... | }
} | random_line_split | |
htmlbaseelement.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::HTMLBaseElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBaseEl... |
}
pub trait HTMLBaseElementMethods {
}
impl Reflectable for HTMLBaseElement {
fn reflector<'a>(&'a self) -> &'a Reflector {
self.htmlelement.reflector()
}
}
| {
let element = HTMLBaseElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLBaseElementBinding::Wrap)
} | identifier_body |
htmlbaseelement.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::HTMLBaseElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBaseEl... | (localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLBaseElement> {
let element = HTMLBaseElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLBaseElementBinding::Wrap)
}
}
pub trait HTMLBaseElementMethods {
}
impl Reflectable for HTMLBaseElemen... | new | identifier_name |
canvasgradient.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 canvas_traits::{CanvasGradientStop, FillOrStrokeStyle, LinearGradientStyle, RadialGradientStyle};
use cssparse... | (global: GlobalRef, style: CanvasGradientStyle) -> Root<CanvasGradient> {
reflect_dom_object(box CanvasGradient::new_inherited(style),
global,
CanvasGradientBinding::Wrap)
}
}
impl CanvasGradientMethods for CanvasGradient {
// https://html.spec.what... | new | identifier_name |
canvasgradient.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 canvas_traits::{CanvasGradientStop, FillOrStrokeStyle, LinearGradientStyle, RadialGradientStyle};
use cssparse... | match color {
Ok(CSSColor::RGBA(rgba)) => rgba,
Ok(CSSColor::CurrentColor) => RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 },
_ => return Err(Error::Syntax)
}
} else {
return Err(Error::Syntax)
};
self.sto... |
let mut parser = Parser::new(&color);
let color = CSSColor::parse(&mut parser);
let color = if parser.is_exhausted() { | random_line_split |
unboxed-closures-blanket-fn-mut.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 x = c(&mut || 22);
assert_eq!(x, 22);
} | assert_eq!(x, 22); | random_line_split |
unboxed-closures-blanket-fn-mut.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 c<F:FnMut() -> i32>(f: &mut F) -> i32 {
a(f)
}
fn main() {
let z: isize = 7;
let x = b(&mut || 22);
assert_eq!(x, 22);
let x = c(&mut || 22);
assert_eq!(x, 22);
}
| {
a(f)
} | identifier_body |
unboxed-closures-blanket-fn-mut.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 ... | <F:FnMut() -> i32>(f: &mut F) -> i32 {
a(f)
}
fn main() {
let z: isize = 7;
let x = b(&mut || 22);
assert_eq!(x, 22);
let x = c(&mut || 22);
assert_eq!(x, 22);
}
| c | identifier_name |
tablet_tool.rs | //! TODO Documentation
use std::{cell::Cell, ptr::NonNull, rc::Rc};
use wlroots_sys::{wlr_input_device, wlr_tablet, wlr_tablet_tool_axes};
pub use crate::events::tablet_tool_events as event;
pub use crate::manager::tablet_tool_handler::*;
use crate::{
input::{self, InputState},
utils::{self, HandleErr, Handle... | (&self) -> Handle {
Handle {
ptr: self.tool,
handle: Rc::downgrade(&self.liveliness),
// NOTE Rationale for cloning:
// Since we have a strong reference already,
// the input must still be alive.
data: unsafe { Some(self.device.as_non_null(... | weak_reference | identifier_name |
tablet_tool.rs | //! TODO Documentation
use std::{cell::Cell, ptr::NonNull, rc::Rc};
use wlroots_sys::{wlr_input_device, wlr_tablet, wlr_tablet_tool_axes};
pub use crate::events::tablet_tool_events as event;
pub use crate::manager::tablet_tool_handler::*;
use crate::{
input::{self, InputState},
utils::{self, HandleErr, Handle... |
fn weak_reference(&self) -> Handle {
Handle {
ptr: self.tool,
handle: Rc::downgrade(&self.liveliness),
// NOTE Rationale for cloning:
// Since we have a strong reference already,
// the input must still be alive.
data: unsafe { Some(se... | } | random_line_split |
tablet_tool.rs | //! TODO Documentation
use std::{cell::Cell, ptr::NonNull, rc::Rc};
use wlroots_sys::{wlr_input_device, wlr_tablet, wlr_tablet_tool_axes};
pub use crate::events::tablet_tool_events as event;
pub use crate::manager::tablet_tool_handler::*;
use crate::{
input::{self, InputState},
utils::{self, HandleErr, Handle... |
}
| {
Handle {
ptr: self.tool,
handle: Rc::downgrade(&self.liveliness),
// NOTE Rationale for cloning:
// Since we have a strong reference already,
// the input must still be alive.
data: unsafe { Some(self.device.as_non_null()) },
... | identifier_body |
version.rs | // Copyright (c) 2015 Y. T. Chung <zonyitoo@gmail.com>
// 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. All files in the project carrying such
// notice may... | fn from_str(s: &str) -> Option<Version> {
let mut sp = s.split('.');
let major = match sp.next() {
Some(s) => try_option!(s.parse()),
None => return None,
};
let minor = match sp.next() {
Some(s) => try_option!(s.parse()),
None => 0,
... | random_line_split | |
version.rs | // Copyright (c) 2015 Y. T. Chung <zonyitoo@gmail.com>
// 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. All files in the project carrying such
// notice may... | (major: u32, minor: u32, patch: u32) -> Version {
Version(major, minor, patch)
}
}
impl Display for Version {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let &Version(major, minor, patch) = self;
write!(f, "{}:{}:{}", major, minor, patch)
}
}
macro_rules! try_option(
($in... | new | identifier_name |
node_style.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Style retrieval from DOM elements.
use css::node_util::NodeUtil;
use layout::incremental::RestyleDamage;
use l... | (&self) -> RestyleDamage {
self.get_restyle_damage()
}
}
| restyle_damage | identifier_name |
node_style.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Style retrieval from DOM elements.
use css::node_util::NodeUtil;
use layout::incremental::RestyleDamage;
use l... |
}
| {
self.get_restyle_damage()
} | identifier_body |
node_style.rs | /* This Source Code Form is subject to the terms of the Mozilla Public | * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Style retrieval from DOM elements.
use css::node_util::NodeUtil;
use layout::incremental::RestyleDamage;
use layout::wrapper::ThreadSafeLayoutNode;
use extra::arc::Arc;
use style::... | random_line_split | |
mod.rs | // Copyright 2013 The rust-gobject authors.
//
// 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... | (object: glib::gpointer) -> glib::gpointer {
#[fixed_stack_segment]; #[inline(never)];
assert!(ptr::is_not_null(object));
native::g_object_ref_sink(object)
}
pub unsafe fn g_object_unref(object: glib::gpointer) {
#[fixed_stack_segment]; #[inline(never)];
assert!(ptr::is_not_null(object));
nativ... | g_object_ref_sink | identifier_name |
mod.rs | // Copyright 2013 The rust-gobject authors.
//
// 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... |
pub unsafe fn g_object_unref(object: glib::gpointer) {
#[fixed_stack_segment]; #[inline(never)];
assert!(ptr::is_not_null(object));
native::g_object_unref(object)
}
| {
#[fixed_stack_segment]; #[inline(never)];
assert!(ptr::is_not_null(object));
native::g_object_ref_sink(object)
} | identifier_body |
mod.rs | // Copyright 2013 The rust-gobject authors.
//
// 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... | pub unsafe fn g_object_ref(object: glib::gpointer) -> glib::gpointer {
#[fixed_stack_segment]; #[inline(never)];
assert!(ptr::is_not_null(object));
native::g_object_ref(object)
}
pub unsafe fn g_object_ref_sink(object: glib::gpointer) -> glib::gpointer {
#[fixed_stack_segment]; #[inline(never)];
as... | random_line_split | |
logging.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::Error;
use consensus_types::common::{Author, Round};
use diem_logger::Schema;
use diem_types::waypoint::Waypoint;
use serde::Serialize;
#[derive(Schema)]
pub struct SafetyLogSchema<'a> {
name: LogEntry,
event: LogEve... | {
ConsensusState,
ConstructAndSignVote,
Epoch,
Initialize,
KeyReconciliation,
LastVotedRound,
PreferredRound,
SignProposal,
SignTimeout,
State,
Waypoint,
}
impl LogEntry {
pub fn as_str(&self) -> &'static str {
match self {
LogEntry::ConsensusState =... | LogEntry | identifier_name |
logging.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::Error;
use consensus_types::common::{Author, Round};
use diem_logger::Schema;
use diem_types::waypoint::Waypoint;
use serde::Serialize;
#[derive(Schema)] | event: LogEvent,
round: Option<Round>,
preferred_round: Option<u64>,
last_voted_round: Option<u64>,
epoch: Option<u64>,
#[schema(display)]
error: Option<&'a Error>,
waypoint: Option<Waypoint>,
author: Option<Author>,
}
impl<'a> SafetyLogSchema<'a> {
pub fn new(name: LogEntry, ev... | pub struct SafetyLogSchema<'a> {
name: LogEntry, | random_line_split |
nonzero.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... | unsafe impl Zeroable for i16 {}
unsafe impl Zeroable for u16 {}
unsafe impl Zeroable for i32 {}
unsafe impl Zeroable for u32 {}
unsafe impl Zeroable for i64 {}
unsafe impl Zeroable for u64 {}
/// A wrapper type for raw pointers and integers that will never be
/// NULL or 0 that might allow certain optimizations.
#[lan... | unsafe impl Zeroable for i8 {}
unsafe impl Zeroable for u8 {} | random_line_split |
nonzero.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... | (&self) -> &T {
let NonZero(ref inner) = *self;
inner
}
}
impl<T: Zeroable+CoerceUnsized<U>, U: Zeroable> CoerceUnsized<NonZero<U>> for NonZero<T> {}
| deref | identifier_name |
nonzero.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... |
}
impl<T: Zeroable+CoerceUnsized<U>, U: Zeroable> CoerceUnsized<NonZero<U>> for NonZero<T> {}
| {
let NonZero(ref inner) = *self;
inner
} | identifier_body |
lint-unsafe-block.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 ... | () {
unsafe {} //~ ERROR: usage of an `unsafe` block
unsafe_in_macro!()
}
| main | identifier_name |
lint-unsafe-block.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 ... |
unsafe fn allowed() {}
#[allow(unsafe_block)] fn also_allowed() { unsafe {} }
macro_rules! unsafe_in_macro {
() => {
unsafe {} //~ ERROR: usage of an `unsafe` block
}
}
fn main() {
unsafe {} //~ ERROR: usage of an `unsafe` block
unsafe_in_macro!()
} | #![allow(dead_code)]
#![deny(unsafe_block)]
#![feature(macro_rules)] | random_line_split |
lint-unsafe-block.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 ... | {
unsafe {} //~ ERROR: usage of an `unsafe` block
unsafe_in_macro!()
} | identifier_body | |
autoderef-full-lval.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
a: Gc<int>,
}
fn main() {
let a: clam = clam{x: box(GC) 1, y: box(GC) 2};
let b: clam = clam{x: box(GC) 10, y: box(GC) 20};
let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Gc<int>`
println!("{:?}", z);
assert_eq!(z, 21);
let forty: fish = fish{a: box(GC)... | fish | identifier_name |
autoderef-full-lval.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | extern crate debug;
use std::gc::{Gc, GC};
struct clam {
x: Gc<int>,
y: Gc<int>,
}
struct fish {
a: Gc<int>,
}
fn main() {
let a: clam = clam{x: box(GC) 1, y: box(GC) 2};
let b: clam = clam{x: box(GC) 10, y: box(GC) 20};
let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applie... | random_line_split | |
distrib.rs | use mopa::Any;
use builder::context::Context;
use builder::commands::alpine;
use builder::error::StepError;
use builder::packages;
/// This returns the same as Distribution::name but is separate trait because
/// static methods makes trait non-object-safe
pub trait Named {
/// Human-readable name of distribution... | (&mut self, ctx: &mut Context) -> Result<(), StepError> {
if (**self).is::<Unknown>() {
try!(alpine::configure(self, ctx, alpine::LATEST_VERSION));
}
Ok(())
}
}
| npm_configure | identifier_name |
distrib.rs | use mopa::Any;
use builder::context::Context;
use builder::commands::alpine;
use builder::error::StepError;
use builder::packages;
/// This returns the same as Distribution::name but is separate trait because
/// static methods makes trait non-object-safe
pub trait Named {
/// Human-readable name of distribution... |
}
pub trait DistroBox {
fn set<D: Distribution+Sized>(&mut self, value: D) -> Result<(), StepError>;
fn specific<T, R, F>(&mut self, f: F) -> Result<R, StepError>
where T: Distribution+Named, R: Sized,
F: FnOnce(&mut T) -> Result<R, StepError>;
fn npm_configure(&mut self, ctx: &mut C... | {
Err(StepError::NoDistro)
} | identifier_body |
distrib.rs | use mopa::Any;
use builder::context::Context;
use builder::commands::alpine;
use builder::error::StepError;
use builder::packages;
/// This returns the same as Distribution::name but is separate trait because
/// static methods makes trait non-object-safe
pub trait Named {
/// Human-readable name of distribution... |
/// Does distro-specific cleanup at the end of the build
fn finish(&mut self, &mut Context) -> Result<(), String> { Ok(()) }
/// Install normal packages
fn install(&mut self, &mut Context, &[String]) -> Result<(), StepError>;
/// Install special predefined packages for specific features
fn en... |
/// Downloads initial image of distribution
fn bootstrap(&mut self, &mut Context) -> Result<(), StepError>; | random_line_split |
distrib.rs | use mopa::Any;
use builder::context::Context;
use builder::commands::alpine;
use builder::error::StepError;
use builder::packages;
/// This returns the same as Distribution::name but is separate trait because
/// static methods makes trait non-object-safe
pub trait Named {
/// Human-readable name of distribution... |
Ok(())
}
}
| {
try!(alpine::configure(self, ctx, alpine::LATEST_VERSION));
} | conditional_block |
main.rs | extern crate sdl;
//use sdl::event::Event;
#[macro_use]
extern crate log;
extern crate env_logger;
#[macro_use]
extern crate clap;
mod chipate;
mod display;
use chipate::Chipate;
fn main() {
env_logger::init().unwrap();
let matches = clap_app!(myapp =>
(version: "1.0")
... |
let program = matches.value_of("program").unwrap();
debug!("Value for program: {}", program);
let clock = matches.value_of("clock").unwrap();
debug!("Value for clock: {}", clock);
let mut chip = Chipate::new();
chip.init();
// chip.load_program("PONG");
chip.load_program(program);
... | random_line_split | |
main.rs | extern crate sdl;
//use sdl::event::Event;
#[macro_use]
extern crate log;
extern crate env_logger;
#[macro_use]
extern crate clap;
mod chipate;
mod display;
use chipate::Chipate;
fn | () {
env_logger::init().unwrap();
let matches = clap_app!(myapp =>
(version: "1.0")
(author: "Robert J. Lambert III <rlambert85@gmail.com>")
(about: "Chip8 Emulator written in rust")
(@arg program: -p... | main | identifier_name |
main.rs | extern crate sdl;
//use sdl::event::Event;
#[macro_use]
extern crate log;
extern crate env_logger;
#[macro_use]
extern crate clap;
mod chipate;
mod display;
use chipate::Chipate;
fn main() | chip.load_program(program);
chip.set_clock_speed(clock.parse::<u64>().unwrap());
loop {
chip.emulate_cycle();
chip.display.draw_screen();
chip.set_keys();
}
}
| {
env_logger::init().unwrap();
let matches = clap_app!(myapp =>
(version: "1.0")
(author: "Robert J. Lambert III <rlambert85@gmail.com>")
(about: "Chip8 Emulator written in rust")
(@arg program: -p --... | identifier_body |
size_hint.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
use core::iter::Peekable;
struct A<T> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Item = $T;
fn next(&mut self) -> Option<Self::Item> {
if s... | () {
let a: A<T> = A { begin: 0, end: 10 };
let mut peekable: Peekable<A<T>> = a.peekable();
peekable.next();
let (lower, upper): (usize, Option<usize>) = peekable.size_hint();
assert_eq!(lower, 9);
assert_eq!(upper, Some::<usize>(9));
}
}
| size_hint_test2 | identifier_name |
size_hint.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
use core::iter::Peekable;
struct A<T> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Item = $T; |
fn next(&mut self) -> Option<Self::Item> {
if self.begin < self.end {
let result = self.begin;
self.begin = self.begin.wrapping_add(1);
Some::<Self::Item>(result)
} else {
None::<Self::Item>
}
}
fn size_hint(&self) -> (usize, Option<usize>) {
debug_assert!(self.begin <= self.... | random_line_split | |
size_hint.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
use core::iter::Peekable;
struct A<T> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Item = $T;
fn next(&mut self) -> Option<Self::Item> {
if s... |
#[test]
fn size_hint_test2() {
let a: A<T> = A { begin: 0, end: 10 };
let mut peekable: Peekable<A<T>> = a.peekable();
peekable.next();
let (lower, upper): (usize, Option<usize>) = peekable.size_hint();
assert_eq!(lower, 9);
assert_eq!(upper, Some::<usize>(9));
}
}
| {
let a: A<T> = A { begin: 0, end: 10 };
let peekable: Peekable<A<T>> = a.peekable();
let (lower, upper): (usize, Option<usize>) = peekable.size_hint();
assert_eq!(lower, 10);
assert_eq!(upper, Some::<usize>(10));
} | identifier_body |
chain.rs | use futures_core::ready;
use futures_core::task::{Context, Poll};
#[cfg(feature = "read-initializer")]
use futures_io::Initializer;
use futures_io::{AsyncBufRead, AsyncRead, IoSliceMut};
use pin_project_lite::pin_project;
use std::fmt;
use std::io;
use std::pin::Pin;
pin_project! {
/// Reader for the [`chain`](sup... | }
/// Gets pinned mutable references to the underlying readers in this `Chain`.
///
/// Care should be taken to avoid modifying the internal I/O state of the
/// underlying readers as doing so may corrupt the internal state of this
/// `Chain`.
pub fn get_pin_mut(self: Pin<&mut Self>) -> (P... | (&mut self.first, &mut self.second) | random_line_split |
chain.rs | use futures_core::ready;
use futures_core::task::{Context, Poll};
#[cfg(feature = "read-initializer")]
use futures_io::Initializer;
use futures_io::{AsyncBufRead, AsyncRead, IoSliceMut};
use pin_project_lite::pin_project;
use std::fmt;
use std::io;
use std::pin::Pin;
pin_project! {
/// Reader for the [`chain`](sup... |
fn consume(self: Pin<&mut Self>, amt: usize) {
let this = self.project();
if!*this.done_first {
this.first.consume(amt)
} else {
this.second.consume(amt)
}
}
}
| {
let this = self.project();
if !*this.done_first {
match ready!(this.first.poll_fill_buf(cx)?) {
buf if buf.is_empty() => {
*this.done_first = true;
}
buf => return Poll::Ready(Ok(buf)),
}
}
thi... | identifier_body |
chain.rs | use futures_core::ready;
use futures_core::task::{Context, Poll};
#[cfg(feature = "read-initializer")]
use futures_io::Initializer;
use futures_io::{AsyncBufRead, AsyncRead, IoSliceMut};
use pin_project_lite::pin_project;
use std::fmt;
use std::io;
use std::pin::Pin;
pin_project! {
/// Reader for the [`chain`](sup... |
}
}
| {
this.second.consume(amt)
} | conditional_block |
chain.rs | use futures_core::ready;
use futures_core::task::{Context, Poll};
#[cfg(feature = "read-initializer")]
use futures_io::Initializer;
use futures_io::{AsyncBufRead, AsyncRead, IoSliceMut};
use pin_project_lite::pin_project;
use std::fmt;
use std::io;
use std::pin::Pin;
pin_project! {
/// Reader for the [`chain`](sup... | (self) -> (T, U) {
(self.first, self.second)
}
}
impl<T, U> fmt::Debug for Chain<T, U>
where
T: fmt::Debug,
U: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Chain")
.field("t", &self.first)
.field("u", &self.second)
... | into_inner | identifier_name |
main.rs | #![allow(dead_code)]
extern crate mio;
use self::mio::{Ready, PollOpt, Token};
use node::{Node, NET_RECEIVER_CHANNEL_TOKEN};
use network::{ConnectionIdentity, Connection, TcpNetwork, SocketType, TcpHandlerCommand, TcpHandlerCMD};
use helper::{Log, NetHelper};
use event::{Event};
use std::error::Error;
use std::proce... | {
pub cmd: NetworkCMD,
pub token: Vec<String>,
pub value: Vec<u64>,
pub conn_identity: Vec<ConnectionIdentity>,
pub event: Vec<Event>
}
pub trait Networking {
/// Main function to init Networking
fn init_networking(&mut self);
/// Handle Networking channel events as a NetworkCommand
... | NetworkCommand | identifier_name |
main.rs | #![allow(dead_code)]
extern crate mio;
use self::mio::{Ready, PollOpt, Token};
use node::{Node, NET_RECEIVER_CHANNEL_TOKEN};
use network::{ConnectionIdentity, Connection, TcpNetwork, SocketType, TcpHandlerCommand, TcpHandlerCMD};
use helper::{Log, NetHelper};
use event::{Event};
use std::error::Error;
use std::proce... |
#[inline(always)]
fn emit(&mut self, event: Event) {
let mut tcp_conns_to_send: Vec<Vec<Token>> = vec![Vec::new(); self.net_tcp_handler_sender_chan.len()];
let mut event = event;
for (_, mut conn) in &mut self.connections {
if conn.value == 0 {
continue;
... | {
let token_len = self.token.len();
let total_value_len = token_len + 8;
// adding 4 byte API version
// 4 Bytes token string length
// N bytes for token string
// 8 bytes for Prime Value
let mut buffer = vec![0; (4 + 4 + token_len + 8)];
let mut offset = ... | identifier_body |
main.rs | #![allow(dead_code)]
extern crate mio;
use self::mio::{Ready, PollOpt, Token};
use node::{Node, NET_RECEIVER_CHANNEL_TOKEN};
use network::{ConnectionIdentity, Connection, TcpNetwork, SocketType, TcpHandlerCommand, TcpHandlerCMD};
use helper::{Log, NetHelper};
use event::{Event};
use std::error::Error;
use std::proce... | impl Networking for Node {
#[inline(always)]
fn notify(&mut self, command: &mut NetworkCommand) {
match command.cmd {
NetworkCMD::HandleConnection => {
// currently supporting only one connection per single command request
if command.token.len()!= 1
... | random_line_split | |
main.rs | #![allow(dead_code)]
extern crate mio;
use self::mio::{Ready, PollOpt, Token};
use node::{Node, NET_RECEIVER_CHANNEL_TOKEN};
use network::{ConnectionIdentity, Connection, TcpNetwork, SocketType, TcpHandlerCommand, TcpHandlerCMD};
use helper::{Log, NetHelper};
use event::{Event};
use std::error::Error;
use std::proce... |
}
NetworkCMD::ConnectionClose => {
// currently supporting only one connection per single command request
if command.token.len()!= 1 || command.conn_identity.len()!= 1 {
return;
}
let token = command.token.rem... | {
// if we have API connection
if value == 0 {
self.on_new_api_connection(&token);
} else { // if we have regular Node connection
self.on_new_connection(&token, value);
}
} | conditional_block |
cube.rs | extern crate piston_window;
extern crate vecmath;
extern crate camera_controllers;
#[macro_use]
extern crate gfx;
extern crate gfx_device_gl;
extern crate sdl2_window;
extern crate piston_meta;
extern crate piston_meta_search;
extern crate shader_version;
use shader_version::Shaders;
use shader_version::glsl::GLSL;
us... | (pos: [f32; 3]) -> Vertex {
Vertex {
a_pos: pos,
}
}
}
gfx_pipeline!( pipe {
vbuf: gfx::VertexBuffer<Vertex> = (),
u_model_view_proj: gfx::Global<[[f32; 4]; 4]> = "u_model_view_proj",
out_color: gfx::RenderTarget<gfx::format::Rgba8> = "o_Color",
out_depth: gfx::DepthTarg... | new | identifier_name |
cube.rs | extern crate piston_window;
extern crate vecmath;
extern crate camera_controllers;
#[macro_use]
extern crate gfx;
extern crate gfx_device_gl;
extern crate sdl2_window;
extern crate piston_meta;
extern crate piston_meta_search;
extern crate shader_version;
use shader_version::Shaders;
use shader_version::glsl::GLSL;
us... | CameraPerspective {
fov: 90.0, near_clip: 0.1, far_clip: 1000.0,
aspect_ratio: (draw_size.width as f32) / (draw_size.height as f32)
}.projection()
};
let model = vecmath::mat4_id();
let mut projection = get_projection(&events);
let mut first_person = FirstPerson:... | pipe::new()
).unwrap();
let get_projection = |w: &PistonWindow<(), Sdl2Window>| {
let draw_size = w.window.borrow().draw_size(); | random_line_split |
cube.rs | extern crate piston_window;
extern crate vecmath;
extern crate camera_controllers;
#[macro_use]
extern crate gfx;
extern crate gfx_device_gl;
extern crate sdl2_window;
extern crate piston_meta;
extern crate piston_meta_search;
extern crate shader_version;
use shader_version::Shaders;
use shader_version::glsl::GLSL;
us... |
}
}
| {
projection = get_projection(&e);
} | conditional_block |
cube.rs | extern crate piston_window;
extern crate vecmath;
extern crate camera_controllers;
#[macro_use]
extern crate gfx;
extern crate gfx_device_gl;
extern crate sdl2_window;
extern crate piston_meta;
extern crate piston_meta_search;
extern crate shader_version;
use shader_version::Shaders;
use shader_version::glsl::GLSL;
us... | // Read cube.ogex.
let mut file_h = File::open("examples/assets/cube.ogex").unwrap();
let mut source = String::new();
file_h.read_to_string(&mut source).unwrap();
let mut data = vec![];
stderr_unwrap(&source, parse(&rules, &source, &mut data));
let s = Search::new(&data);
let vertex_dat... | {
let opengl = OpenGL::V3_2;
let mut events: PistonWindow<(), Sdl2Window> =
WindowSettings::new("piston: cube", [640, 480])
.exit_on_esc(true)
.samples(4)
.opengl(opengl)
.build()
.unwrap();
events.set_capture_cursor(true);
let ref mut factory = events.f... | identifier_body |
regions-early-bound-error-method.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 ... | } | g2.get() //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to
}
}
fn main() { | random_line_split |
regions-early-bound-error-method.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 ... | () {
}
| main | identifier_name |
cssgroupingrule.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::CSSGroupingRuleBinding::CSSGroupingRuleMethods;
use dom::bindings::error::{E... | }
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-deleterule
fn DeleteRule(&self, index: u32) -> ErrorResult {
self.rulelist().remove_rule(index)
}
} |
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-insertrule
fn InsertRule(&self, rule: DOMString, index: u32) -> Fallible<u32> {
self.rulelist().insert_rule(&rule, index, /* nested */ true) | random_line_split |
cssgroupingrule.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::CSSGroupingRuleBinding::CSSGroupingRuleMethods;
use dom::bindings::error::{E... | (&self) -> DomRoot<CSSRuleList> {
let parent_stylesheet = self.upcast::<CSSRule>().parent_stylesheet();
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
parent_stylesheet,
RulesSource:... | rulelist | identifier_name |
cssgroupingrule.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::CSSGroupingRuleBinding::CSSGroupingRuleMethods;
use dom::bindings::error::{E... |
}
impl CSSGroupingRuleMethods for CSSGroupingRule {
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-cssrules
fn CssRules(&self) -> DomRoot<CSSRuleList> {
// XXXManishearth check origin clean flag
self.rulelist()
}
// https://drafts.csswg.org/cssom/#dom-cssgroupingrule-insertrul... | {
self.cssrule.shared_lock()
} | identifier_body |
directory.rs | use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter};
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
use hex;
use serde_json;
use core::{Dependency, Package, PackageId, Source, SourceId, Summary}; |
pub struct DirectorySource<'cfg> {
source_id: SourceId,
root: PathBuf,
packages: HashMap<PackageId, (Package, Checksum)>,
config: &'cfg Config,
}
#[derive(Deserialize)]
struct Checksum {
package: Option<String>,
files: HashMap<String, String>,
}
impl<'cfg> DirectorySource<'cfg> {
pub fn n... | use sources::PathSource;
use util::{Config, Sha256};
use util::errors::{CargoResult, CargoResultExt};
use util::paths; | random_line_split |
directory.rs | use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter};
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
use hex;
use serde_json;
use core::{Dependency, Package, PackageId, Source, SourceId, Summary};
use sources::PathSource;
use util::{Config, Sha256};
use util::errors::{CargoRes... | (&self, f: &mut Formatter) -> fmt::Result {
write!(f, "DirectorySource {{ root: {:?} }}", self.root)
}
}
impl<'cfg> Source for DirectorySource<'cfg> {
fn query(&mut self, dep: &Dependency, f: &mut FnMut(Summary)) -> CargoResult<()> {
let packages = self.packages.values().map(|p| &p.0);
... | fmt | identifier_name |
directory.rs | use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter};
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
use hex;
use serde_json;
use core::{Dependency, Package, PackageId, Source, SourceId, Summary};
use sources::PathSource;
use util::{Config, Sha256};
use util::errors::{CargoRes... |
// Vendor directories are often checked into a VCS, but throughout
// the lifetime of a vendor dir crates are often added and deleted.
// Some VCS implementations don't always fully delete the directory
// when a dir is removed from a different checkout. Sometimes a
... | {
if s.starts_with('.') {
continue;
}
} | conditional_block |
directory.rs | use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter};
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
use hex;
use serde_json;
use core::{Dependency, Package, PackageId, Source, SourceId, Summary};
use sources::PathSource;
use util::{Config, Sha256};
use util::errors::{CargoRes... | }
// Vendor directories are often checked into a VCS, but throughout
// the lifetime of a vendor dir crates are often added and deleted.
// Some VCS implementations don't always fully delete the directory
// when a dir is removed from a different checkout. So... | {
self.packages.clear();
let entries = self.root.read_dir().chain_err(|| {
format!(
"failed to read root of directory source: {}",
self.root.display()
)
})?;
for entry in entries {
let entry = entry?;
let pa... | identifier_body |
literals.rs | fn | () {
// Suffixed literals, their types are known at initialization
let x = 1u8;
let y = 2u32;
let z = 3f32;
// Unsuffixed literal, their types depend on how they are used
let i = 1;
let f = 1.0;
// `size_of_val` returns the size of a variable in bytes
println!("size of `x` in bytes... | main | identifier_name |
literals.rs | fn main() {
// Suffixed literals, their types are known at initialization
let x = 1u8;
let y = 2u32;
let z = 3f32;
// Unsuffixed literal, their types depend on how they are used
let i = 1;
let f = 1.0;
// `size_of_val` returns the size of a variable in bytes
println!("size of `x` i... | println!("size of `f` in bytes: {}", std::mem::size_of_val(&f));
} | random_line_split | |
literals.rs | fn main() | {
// Suffixed literals, their types are known at initialization
let x = 1u8;
let y = 2u32;
let z = 3f32;
// Unsuffixed literal, their types depend on how they are used
let i = 1;
let f = 1.0;
// `size_of_val` returns the size of a variable in bytes
println!("size of `x` in bytes: {... | identifier_body | |
const-binops.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 ... | () {
assert_eq!(A, -1);
assert_eq!(A2, 6);
assert_approx_eq!(B, 5.7);
assert_eq!(C, -1);
assert_eq!(D, 0);
assert_approx_eq!(E, 0.3);
assert_eq!(E2, -9);
assert_eq!(F, 9);
assert_approx_eq!(G, 10.89);
assert_eq!(H, -3);
assert_eq!(I, 1);
assert_approx_eq!(J, 1.0);
... | main | identifier_name |
const-binops.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 ... | static U: uint = 1 ^ 3;
static V: int = 1 << 3;
// NOTE: better shr coverage
static W: int = 1024 >> 4;
static X: uint = 1024 >> 4;
static Y: bool = 1i == 1;
static Z: bool = 1.0f64 == 1.0;
static AA: bool = 1i <= 2;
static AB: bool = -1i <= 2;
static AC: bool = 1.0f64 <= 2.0;
static AD: bool = 1i < 2;
static AE: ... |
static T: int = 3 ^ 1; | random_line_split |
const-binops.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 ... |
assert_eq!(P, 1);
assert_eq!(Q, 1);
assert_eq!(R, 3);
assert_eq!(S, 3);
assert_eq!(T, 2);
assert_eq!(U, 2);
assert_eq!(V, 8);
assert_eq!(W, 64);
assert_eq!(X, 64);
assert_eq!(Y, true);
assert_eq!(Z, true);
assert_eq!(AA, true);
assert_eq!(AB, true);
assert_... | {
assert_eq!(A, -1);
assert_eq!(A2, 6);
assert_approx_eq!(B, 5.7);
assert_eq!(C, -1);
assert_eq!(D, 0);
assert_approx_eq!(E, 0.3);
assert_eq!(E2, -9);
assert_eq!(F, 9);
assert_approx_eq!(G, 10.89);
assert_eq!(H, -3);
assert_eq!(I, 1);
assert_approx_eq!(J, 1.0);
as... | identifier_body |
main.rs | //! # Standalone Pact Verifier
//!
//! This project provides a command line interface to verify pact files against a running provider. It is a single executable binary. It implements the [V2 Pact specification](https://github.com/pact-foundation/pact-specification/tree/version-2).
//!
//! [Online rust docs](https://doc... | std::process::exit(err);
}
}
#[cfg(windows)]
fn init_windows() {
if let Err(err) = ansi_term::enable_ansi_support() {
warn!("Could not enable ANSI console support - {err}");
}
}
#[cfg(not(windows))]
fn init_windows() { }
| {
init_windows();
let runtime = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.expect("Could not start a Tokio runtime for running async tasks");
let result = runtime.block_on(async {
let result = handle_cli(clap::crate_version!()).await;
// Add a small delay to let asy... | identifier_body |
main.rs | //! # Standalone Pact Verifier
//!
//! This project provides a command line interface to verify pact files against a running provider. It is a single executable binary. It implements the [V2 Pact specification](https://github.com/pact-foundation/pact-specification/tree/version-2).
//!
//! [Online rust docs](https://doc... | //! | Option | Type | Description |
//! |--------|------|-------------|
//! | `-f, --file <file>` | File | Loads a pact from the given file |
//! | `-u, --url <url>` | URL | Loads a pact from a URL resource |
//! | `-d, --dir <dir>` | Directory | Loads all the pacts from the given directory |
//! | `-b, --broker-url <b... | //! ### Pact File Sources
//!
//! You can specify the pacts to verify with the following options. They can be repeated to set multiple sources.
//! | random_line_split |
main.rs | //! # Standalone Pact Verifier
//!
//! This project provides a command line interface to verify pact files against a running provider. It is a single executable binary. It implements the [V2 Pact specification](https://github.com/pact-foundation/pact-specification/tree/version-2).
//!
//! [Online rust docs](https://doc... | ,
ErrorKind::VersionDisplayed => {
print_version(version);
println!();
Ok(())
},
_ => {
err.exit()
}
}
}
}
}
async fn handle_matches(matches: &clap::ArgMatches<'_>) -> Result<(), i32> {
let level = matches.value_of("loglevel").unwrap... | {
println!("{}", err.message);
Ok(())
} | conditional_block |
main.rs | //! # Standalone Pact Verifier
//!
//! This project provides a command line interface to verify pact files against a running provider. It is a single executable binary. It implements the [V2 Pact specification](https://github.com/pact-foundation/pact-specification/tree/version-2).
//!
//! [Online rust docs](https://doc... | (version: &str) {
println!("\npact verifier version : v{}", version);
println!("pact specification : v{}", PactSpecification::V4.version_str());
println!("models version : v{}", PACT_RUST_VERSION.unwrap_or_default());
}
fn pact_source(matches: &ArgMatches) -> Vec<PactSource> {
let mut sources =... | print_version | identifier_name |
lib.rs | // Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#![deny(warnings)]
// Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to... | use std::io::Write;
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
use fs::RelativePath;
pub mod data;
pub mod file;
pub mod path;
pub fn owned_string_vec(args: &[&str]) -> Vec<String> {
args.iter().map(<&str>::to_string).collect()
}
pub fn relative_paths<'a>(paths: &'a [&str]) -> impl Iterator<Item ... | #![allow(clippy::mutex_atomic)]
use bytes::Bytes; | random_line_split |
lib.rs | // Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#![deny(warnings)]
// Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to... |
pub fn make_file(path: &Path, contents: &[u8], mode: u32) {
let mut file = std::fs::File::create(&path).unwrap();
file.write_all(contents).unwrap();
let mut permissions = std::fs::metadata(path).unwrap().permissions();
permissions.set_mode(mode);
file.set_permissions(permissions).unwrap();
}
pub fn append_... | {
Bytes::copy_from_slice(str.as_bytes())
} | identifier_body |
lib.rs | // Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#![deny(warnings)]
// Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to... | (str: &str) -> Bytes {
Bytes::copy_from_slice(str.as_bytes())
}
pub fn make_file(path: &Path, contents: &[u8], mode: u32) {
let mut file = std::fs::File::create(&path).unwrap();
file.write_all(contents).unwrap();
let mut permissions = std::fs::metadata(path).unwrap().permissions();
permissions.set_mode(mode)... | as_bytes | identifier_name |
sphere.rs | use shapes::geometry::Geometry;
use na::{Vector3};
use ray::Ray;
use intersection::RawIntersection;
use shapes::bbox::BBox;
#[derive(PartialEq, Clone)]
pub struct Sphere {
pub center: Vector3<f64>,
pub radius: f64,
}
impl Sphere{
pub fn new(center:Vector3<f64>, radius: f64) -> Sphere {
Sphere {
... |
if dist.is_sign_negative() {
// If dist is negative, ray started inside sphere so find other root
dist = (-b + d.sqrt()) / a;
}
if dist < 0. { return None; }
let point = r.ro + (r.rd.normalize() * dist);
return Some(
RawIntersection {
... | {
let dst = r.ro - self.center;
let a = r.rd.dot(&r.rd);
let b = dst.dot(&r.rd.normalize());
let c = dst.dot(&dst) - self.radius * self.radius;
/*
if c > 0. && b > 0. {
// Exit if r’s origin outside s (c > 0) and r pointing away from s (b > 0)
re... | identifier_body |
sphere.rs | use shapes::geometry::Geometry;
use na::{Vector3};
use ray::Ray;
use intersection::RawIntersection;
use shapes::bbox::BBox;
#[derive(PartialEq, Clone)]
pub struct Sphere {
pub center: Vector3<f64>,
pub radius: f64,
}
impl Sphere{
pub fn new(center:Vector3<f64>, radius: f64) -> Sphere {
Sphere {
... | self) -> BBox {
BBox::new(
Vector3::new(&self.center.x - &self.radius,
&self.center.y - &self.radius,
&self.center.z - &self.radius
),
Vector3::new(&self.center.x + &self.radius,
&self.center.y + &... | unds(& | identifier_name |
sphere.rs | use shapes::geometry::Geometry;
use na::{Vector3};
use ray::Ray;
use intersection::RawIntersection;
use shapes::bbox::BBox;
#[derive(PartialEq, Clone)]
pub struct Sphere {
pub center: Vector3<f64>,
pub radius: f64,
}
impl Sphere{
pub fn new(center:Vector3<f64>, radius: f64) -> Sphere {
Sphere {
... | ),
Vector3::new(&self.center.x + &self.radius,
&self.center.y + &self.radius,
&self.center.z + &self.radius
),
)
}
} | BBox::new(
Vector3::new(&self.center.x - &self.radius,
&self.center.y - &self.radius,
&self.center.z - &self.radius | random_line_split |
sphere.rs | use shapes::geometry::Geometry;
use na::{Vector3};
use ray::Ray;
use intersection::RawIntersection;
use shapes::bbox::BBox;
#[derive(PartialEq, Clone)]
pub struct Sphere {
pub center: Vector3<f64>,
pub radius: f64,
}
impl Sphere{
pub fn new(center:Vector3<f64>, radius: f64) -> Sphere {
Sphere {
... | let point = r.ro + (r.rd.normalize() * dist);
return Some(
RawIntersection {
dist: dist,
point: point,
normal: (point - self.center).normalize()
})
}
fn bounds(&self) -> BBox {
BBox::new(
Vector3::new(... | return None; }
| conditional_block |
led.rs | //! LED *(Dialog-specification language)* functionalities.
//!
//! LED is a dialog-specification language whose purpose is not to be a complete programming language,
//! but rather to make dialog specification simpler than in C. Additionally it allows users to easily
//! edit your application layout from external files... |
/// Compiles a LED specification from a string.
///
/// See the `load` function for additional semantic details.
pub fn load_buffer<S: Into<String>>(buf: S) -> Result<(), String> {
let cstr = CString::new(buf.into()).unwrap();
match unsafe { iup_sys::IupLoadBuffer(cstr.as_ptr()) } {
err if err.is_null(... | match unsafe { iup_sys::IupLoad(cstr.as_ptr()) } {
err if err.is_null() => Ok(()),
err => Err(string_from_cstr!(err)),
}
} | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.