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
main.rs
extern crate winapi; extern crate user32; extern crate gdi32; extern crate comctl32; extern crate kernel32; use std::ptr::null_mut; use std::mem::size_of; use std::mem::zeroed; use std::os::raw::c_int; use winapi::winnt::MAKELANGID; use winapi::winnt::LANG_NEUTRAL; use winapi::winnt::SUBLANG_DEFAULT; use winapi::winu...
else { Some(self.pe32) } } else { if kernel32::Process32NextW(self.snapshot, &mut self.pe32) == 0 { None } else { Some(self.pe32) } } } } } impl ToolhelpSnapshot { fn new() -> Res<ToolhelpSnapshot> { unsafe { use winapi::t...
{ None }
conditional_block
main.rs
extern crate winapi; extern crate user32; extern crate gdi32; extern crate comctl32; extern crate kernel32; use std::ptr::null_mut; use std::mem::size_of; use std::mem::zeroed; use std::os::raw::c_int; use winapi::winnt::MAKELANGID; use winapi::winnt::LANG_NEUTRAL; use winapi::winnt::SUBLANG_DEFAULT; use winapi::winu...
fn from_u16(s: &[u16]) -> String { // panic if there's no null terminator let pos = s.iter().position(|a| a == &0u16).unwrap(); use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; let s2: OsString = OsStringExt::from_wide(&s[..pos]); s2.to_string_lossy().to_string() } const IDI_TRAYICON: *con...
{ unsafe { let mut pid: DWORD = 0; if user32::GetWindowThreadProcessId(target, &mut pid as *mut DWORD) != 0 { let ths = ToolhelpSnapshot::new(); ths.and_then(|mut i| { i.find(|pe32| pe32.th32ProcessID == pid) .map(|pe32| from_u16(&pe32.szExeFile)) .ok_or("cannot find pr...
identifier_body
main.rs
extern crate winapi; extern crate user32; extern crate gdi32; extern crate comctl32; extern crate kernel32; use std::ptr::null_mut; use std::mem::size_of; use std::mem::zeroed; use std::os::raw::c_int; use winapi::winnt::MAKELANGID; use winapi::winnt::LANG_NEUTRAL; use winapi::winnt::SUBLANG_DEFAULT; use winapi::winu...
() -> String { unsafe { let mut buf = [0 as WCHAR; 2048]; let res = kernel32::FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, null_mut(), kernel32::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) as DWORD, buf.as_mut_ptr(), buf.len() as DWORD...
last_error
identifier_name
uri_fragment.rs
iter: I, } impl<I: Iterator<Item=char>> UnescapeIter<I> { /// Creates a new UnescapeIter. pub fn new<II: IntoIterator<Item=char, IntoIter=I>>(ii: II) -> UnescapeIter<I> { UnescapeIter { iter: ii.into_iter(), } } } impl<I: Iterator<Item=char>> Iterator for UnescapeIter<I> { ...
use parser::ParseError; /// An iterator that unescapes URI fragments. pub struct UnescapeIter<I: Iterator<Item=char>> {
random_line_split
uri_fragment.rs
use parser::ParseError; /// An iterator that unescapes URI fragments. pub struct
<I: Iterator<Item=char>> { iter: I, } impl<I: Iterator<Item=char>> UnescapeIter<I> { /// Creates a new UnescapeIter. pub fn new<II: IntoIterator<Item=char, IntoIter=I>>(ii: II) -> UnescapeIter<I> { UnescapeIter { iter: ii.into_iter(), } } } impl<I: Iterator<Item=char>> Iter...
UnescapeIter
identifier_name
uri_fragment.rs
use parser::ParseError; /// An iterator that unescapes URI fragments. pub struct UnescapeIter<I: Iterator<Item=char>> { iter: I, } impl<I: Iterator<Item=char>> UnescapeIter<I> { /// Creates a new UnescapeIter. pub fn new<II: IntoIterator<Item=char, IntoIter=I>>(ii: II) -> UnescapeIter<I> { Unescap...
}
{ match ch { '0' => Ok(0), '1' => Ok(1), '2' => Ok(2), '3' => Ok(3), '4' => Ok(4), '5' => Ok(5), '6' => Ok(6), '7' => Ok(7), '8' => Ok(8), '9' => Ok(9), 'a' | 'A' => Ok(10), 'b' | 'B' => Ok(11), 'c' | 'C' => Ok(1...
identifier_body
mod.rs
mod err; use ::descriptor::Descriptor; use ::libc; pub use self::err::{SlaveError, Result}; use std::os::unix::io::{AsRawFd, RawFd}; #[derive(Debug)] pub struct
{ pty: RawFd, } impl Slave { /// The constructor function `new` returns the Slave interface. pub fn new(path: *const ::libc::c_char) -> Result<Self> { match Self::open(path, libc::O_RDWR, None) { Err(cause) => Err(SlaveError::BadDescriptor(cause)), Ok(fd) => Ok(Slave { pty:...
Slave
identifier_name
mod.rs
mod err; use ::descriptor::Descriptor; use ::libc;
pub use self::err::{SlaveError, Result}; use std::os::unix::io::{AsRawFd, RawFd}; #[derive(Debug)] pub struct Slave { pty: RawFd, } impl Slave { /// The constructor function `new` returns the Slave interface. pub fn new(path: *const ::libc::c_char) -> Result<Self> { match Self::open(path, libc::O_...
random_line_split
mod.rs
mod err; use ::descriptor::Descriptor; use ::libc; pub use self::err::{SlaveError, Result}; use std::os::unix::io::{AsRawFd, RawFd}; #[derive(Debug)] pub struct Slave { pty: RawFd, } impl Slave { /// The constructor function `new` returns the Slave interface. pub fn new(path: *const ::libc::c_char) -> R...
pub fn dup2(&self, std: libc::c_int) -> Result<libc::c_int> { unsafe { match libc::dup2(self.as_raw_fd(), std) { -1 => Err(SlaveError::Dup2Error), d => Ok(d), } } } } impl Descriptor for Slave {} impl AsRawFd for Slave { /// The acc...
{ match Self::open(path, libc::O_RDWR, None) { Err(cause) => Err(SlaveError::BadDescriptor(cause)), Ok(fd) => Ok(Slave { pty: fd }), } }
identifier_body
vaesenclast.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vaesenclast_1() { run_test(&Instruction { mnemonic: Mnemonic::VAESENCLAST, operand1: Some(Direct(XMM6)), operand2: Some...
fn vaesenclast_3() { run_test(&Instruction { mnemonic: Mnemonic::VAESENCLAST, operand1: Some(Direct(XMM4)), operand2: Some(Direct(XMM6)), operand3: Some(Direct(XMM7)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 226, 73, 221, 231], OperandS...
{ run_test(&Instruction { mnemonic: Mnemonic::VAESENCLAST, operand1: Some(Direct(XMM3)), operand2: Some(Direct(XMM7)), operand3: Some(IndirectDisplaced(EBX, 153414111, Some(OperandSize::Xmmword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &...
identifier_body
vaesenclast.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vaesenclast_1() { run_test(&Instruction { mnemonic: Mnemonic::VAESENCLAST, operand1: Some(Direct(XMM6)), operand2: Some...
() { run_test(&Instruction { mnemonic: Mnemonic::VAESENCLAST, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XMM3)), operand3: Some(IndirectScaledDisplaced(RBX, Two, 383278263, Some(OperandSize::Xmmword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadc...
vaesenclast_4
identifier_name
vaesenclast.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vaesenclast_1() { run_test(&Instruction { mnemonic: Mnemonic::VAESENCLAST, operand1: Some(Direct(XMM6)), operand2: Some...
fn vaesenclast_3() { run_test(&Instruction { mnemonic: Mnemonic::VAESENCLAST, operand1: Some(Direct(XMM4)), operand2: Some(Direct(XMM6)), operand3: Some(Direct(XMM7)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 226, 73, 221, 231], OperandSiz...
}
random_line_split
lib.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 ...
else {-errcode as uint}, extra: 0, detail: Some(uverr.desc()), } } #[cfg(windows)] pub fn uv_error_to_io_error(uverr: UvError) -> IoError { let UvError(errcode) = uverr; IoError { code: match errcode { uvll::EOF => libc::EOF, uvll::EACCES => libc::ERROR_ACCE...
{libc::EOF as uint}
conditional_block
lib.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 ...
(&mut self) { if!self.defused { unsafe { uvll::free_req(self.handle) } } } } /// FIXME: Loop(*handle) is buggy with destructors. Normal structs /// with dtors may not be destructured, but tuple structs can, /// but the results are not correct. pub struct Loop { handle: *mut uvll::uv...
drop
identifier_name
lib.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 ...
} impl ForbidSwitch { fn new(s: &'static str) -> ForbidSwitch { ForbidSwitch { msg: s, io: homing::local_id(), } } } impl Drop for ForbidSwitch { fn drop(&mut self) { assert!(self.io == homing::local_id(), "didn't want a scheduler switch: {}"...
msg: &'static str, io: uint,
random_line_split
lib.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 ...
pub fn wrap(handle: *mut uvll::uv_loop_t) -> Loop { Loop { handle: handle } } pub fn run(&mut self) { assert_eq!(unsafe { uvll::uv_run(self.handle, uvll::RUN_DEFAULT) }, 0); } pub fn close(&mut self) { unsafe { uvll::uv_loop_delete(self.handle) }; } // The 'data' field of th...
{ let handle = unsafe { uvll::loop_new() }; assert!(handle.is_not_null()); unsafe { uvll::set_data_for_uv_loop(handle, 0 as *mut c_void) } Loop::wrap(handle) }
identifier_body
query.rs
use std::cmp::{max, min}; use serde::Deserialize; use serde_with::{serde_as, CommaSeparator, DisplayFromStr, StringWithSeparator, TryFromInto}; use shakmaty::{ fen::Fen, uci::Uci, variant::{Variant, VariantPosition}, zobrist::Zobrist, CastlingMode, Color, PositionError, }; use crate::{ api::{E...
}) } pub fn top_group(&self) -> Option<RatingGroup> { let mut top_group = None; for group in RatingGroup::ALL.into_iter().rev() { if!self.contains_rating_group(group) || group < RatingGroup::Group2000 { break; } top_group = Some(group)...
RatingGroup::Group1600, min(rating_group, RatingGroup::Group2500), ))
random_line_split
query.rs
use std::cmp::{max, min}; use serde::Deserialize; use serde_with::{serde_as, CommaSeparator, DisplayFromStr, StringWithSeparator, TryFromInto}; use shakmaty::{ fen::Fen, uci::Uci, variant::{Variant, VariantPosition}, zobrist::Zobrist, CastlingMode, Color, PositionError, }; use crate::{ api::{E...
(self, openings: &Openings) -> Result<PlayPosition<'_>, Error> { let variant = Variant::from(self.variant); let mut pos = Zobrist::new(match self.fen { Some(fen) => VariantPosition::from_setup(variant, &fen, CastlingMode::Chess960) .or_else(PositionError::ignore_invalid_castli...
position
identifier_name
restyle_hints.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/. */ //! Restyle hints: an optimization to avoid unnecessarily matching selectors. use attr::{AttrIdentifier, AttrValu...
(&self) -> Option<Self> { self.element.first_child_element().map(ElementWrapper::new) } fn last_child_element(&self) -> Option<Self> { self.element.last_child_element().map(ElementWrapper::new) } fn prev_sibling_element(&self) -> Option<Self> { self.element.prev_sibling_element()...
first_child_element
identifier_name
restyle_hints.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/. */ //! Restyle hints: an optimization to avoid unnecessarily matching selectors. use attr::{AttrIdentifier, AttrValu...
let mut hint = RestyleHint::empty(); for dep in &self.deps { if state_changes.intersects(dep.sensitivities.states) || (attrs_changed && dep.sensitivities.attrs) { let old_el: ElementWrapper<E> = ElementWrapper::new_with_snapshot(el.clone(), snapshot); let matc...
let state_changes = snapshot.state.map_or(ElementState::empty(), |old_state| current_state ^ old_state); let attrs_changed = snapshot.attrs.is_some();
random_line_split
restyle_hints.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/. */ //! Restyle hints: an optimization to avoid unnecessarily matching selectors. use attr::{AttrIdentifier, AttrValu...
fn get_id(&self) -> Option<Atom> { match self.snapshot.attrs { Some(_) => self.snapshot.get_attr(&ns!(), &atom!("id")).map(|value| value.as_atom().clone()), None => self.element.get_id(), } } fn has_class(&self, name: &Atom) -> bool { match self.snapshot.attr...
{ self.element.get_namespace() }
identifier_body
restyle_hints.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/. */ //! Restyle hints: an optimization to avoid unnecessarily matching selectors. use attr::{AttrIdentifier, AttrValu...
} fn parent_element(&self) -> Option<Self> { self.element.parent_element().map(ElementWrapper::new) } fn first_child_element(&self) -> Option<Self> { self.element.first_child_element().map(ElementWrapper::new) } fn last_child_element(&self) -> Option<Self> { self.elemen...
{ match self.snapshot.state { Some(s) => s.contains(flag), None => self.element.match_non_ts_pseudo_class(pseudo_class) } }
conditional_block
predicates.rs
use std::fmt::{Display, Formatter}; use std::fmt::Error; pub trait Predicate<T>: Display where T: Display { fn name(&self) -> &str; fn len(&self) -> usize; fn ids(&self) -> &Vec<T>; fn is_empty(&self) -> bool; } #[derive(Debug)] pub struct Pred<'a, T> where T: Display { name: &'a str, ids:...
} impl<'a, T> Predicate<T> for Pred<'a, T> where T: Display { fn len(&self) -> usize { self.ids.len() } fn name(&self) -> &str { self.name } fn ids(&self) -> &Vec<T> { &self.ids } fn is_empty(&self) -> bool { self.ids.is_empty() } } #[cfg(test)] ...
match *self { ID::Literal(x) => write!(f, "'{}'", x), ID::Variable(x) => write!(f, "{}", x), } }
random_line_split
predicates.rs
use std::fmt::{Display, Formatter}; use std::fmt::Error; pub trait Predicate<T>: Display where T: Display { fn name(&self) -> &str; fn len(&self) -> usize; fn ids(&self) -> &Vec<T>; fn is_empty(&self) -> bool; } #[derive(Debug)] pub struct Pred<'a, T> where T: Display { name: &'a str, ids:...
(&self) -> usize { self.ids.len() } fn name(&self) -> &str { self.name } fn ids(&self) -> &Vec<T> { &self.ids } fn is_empty(&self) -> bool { self.ids.is_empty() } } #[cfg(test)] mod tests { use super::{Stmt, ID, Pred}; #[test] fn queries() { ...
len
identifier_name
predicates.rs
use std::fmt::{Display, Formatter}; use std::fmt::Error; pub trait Predicate<T>: Display where T: Display { fn name(&self) -> &str; fn len(&self) -> usize; fn ids(&self) -> &Vec<T>; fn is_empty(&self) -> bool; } #[derive(Debug)] pub struct Pred<'a, T> where T: Display { name: &'a str, ids:...
} impl<'a> Display for ID<'a> { fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { match *self { ID::Literal(x) => write!(f, "'{}'", x), ID::Variable(x) => write!(f, "{}", x), } } } impl<'a, T> Predicate<T> for Pred<'a, T> where T: Display { fn len(&self) ...
{ write!(f, "{}(", self.name).unwrap(); for (i, ch) in self.ids.iter().enumerate() { if i == 0 { write!(f, "{}", ch).unwrap(); } else { write!(f, ",{}", ch).unwrap(); } } write!(f, ")") }
identifier_body
mod.rs
// // SOS: the Stupid Operating System // by Eliza Weisman (eliza@elizas.website) // // Copyright (c) 2015-2017 Eliza Weisman
//! This module consists of a number of modules containing //! architecture-specific code for each targeted architecture. The `arch` //! module uses conditional compilation to re-export the implementation for //! which the kernel is currently being compiled. //! //! In order for the rest of the kernel to work properly,...
// Released under the terms of the MIT license. See `LICENSE` in the root // directory of this repository for more information. // //! Architecture-specific implementation. //!
random_line_split
prelude.rs
use chrono_tz::Tz; use chrono::{Date, NaiveDate, TimeZone, Utc}; use std::collections::HashMap; use std::fmt::{Display, Formatter}; pub use activity::Activity; pub use std::error::Error; pub use sheet::Sheet; #[derive(Debug)] pub struct LdgrError(pub String); impl Display for LdgrError { fn fmt(&self, f: &mut Fo...
(x: &str) -> Result<String, Box<Error>> { Ok(x.to_string()) } pub fn convert_num(x: &str) -> Result<f64, Box<Error>> { match x { "..." | "" => Ok(0.), _ => Ok(x.to_string() .replace(",", "") .replace("£", "") .parse::<f64>()?), } } pub fn convert_tz(x: &str...
convert_string
identifier_name
prelude.rs
use chrono_tz::Tz; use chrono::{Date, NaiveDate, TimeZone, Utc}; use std::collections::HashMap; use std::fmt::{Display, Formatter}; pub use activity::Activity; pub use std::error::Error; pub use sheet::Sheet; #[derive(Debug)] pub struct LdgrError(pub String); impl Display for LdgrError { fn fmt(&self, f: &mut Fo...
} pub fn convert_string(x: &str) -> Result<String, Box<Error>> { Ok(x.to_string()) } pub fn convert_num(x: &str) -> Result<f64, Box<Error>> { match x { "..." | "" => Ok(0.), _ => Ok(x.to_string() .replace(",", "") .replace("£", "") .parse::<f64>()?), } } p...
)) })?)
random_line_split
boxed.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(&self, other: &Box<T>) -> bool { PartialOrd::gt(&**self, &**other) } } #[stable] impl<T:?Sized + Ord> Ord for Box<T> { #[inline] fn cmp(&self, other: &Box<T>) -> Ordering { Ord::cmp(&**self, &**other) } } #[stable] impl<T:?Sized + Eq> Eq for Box<T> {} impl<S: hash::Hasher, T:?Sized + Hash<S>> Hash...
gt
identifier_name
boxed.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} #[stable] impl<T: Clone> Clone for Box<T> { /// Returns a new box with a `clone()` of this box's contents. /// /// # Examples /// /// ``` /// let x = Box::new(5); /// let y = x.clone(); /// ``` #[inline] fn clone(&self) -> Box<T> { box {(**self).clone()} } /// Copies `so...
{ box [] }
identifier_body
boxed.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
else { Err(self) } } } #[stable] impl<T: fmt::Display +?Sized> fmt::Display for Box<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&**self, f) } } #[stable] impl<T: fmt::Debug +?Sized> fmt::Debug for Box<T> { fn fmt(&self, f: &mut fmt::Format...
{ unsafe { // Get the raw representation of the trait object let to: TraitObject = mem::transmute::<Box<Any>, TraitObject>(self); // Extract the data pointer Ok(mem::transmute(to.data)) } }
conditional_block
boxed.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
impl<T: Clone> Clone for Box<T> { /// Returns a new box with a `clone()` of this box's contents. /// /// # Examples /// /// ``` /// let x = Box::new(5); /// let y = x.clone(); /// ``` #[inline] fn clone(&self) -> Box<T> { box {(**self).clone()} } /// Copies `source`'s conten...
#[stable]
random_line_split
for-loop-no-std.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(_argc: int, _argv: *const *const u8) -> int { for _ in [1,2,3].iter() { } 0 }
start
identifier_name
for-loop-no-std.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
random_line_split
for-loop-no-std.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ for _ in [1,2,3].iter() { } 0 }
identifier_body
sequential.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/. */ //! Implements sequential traversals over the DOM and flow trees. use app_units::Au; use context::LayoutContext; ...
stacking_context_position = Point2D::new(kid.as_block().fragment.margin.inline_start, Au(0)) + kid.base().stacking_relative_position + stacking_context_position.to_vector(); let relative_position = ki...
flow.iterate_through_fragment_border_boxes(iterator, level, stacking_context_position); for kid in flow.mut_base().child_iter_mut() { let mut stacking_context_position = *stacking_context_position; if kid.is_block_flow() && kid.as_block().fragment.establishes_stacking_context() ...
random_line_split
sequential.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/. */ //! Implements sequential traversals over the DOM and flow trees. use app_units::Au; use context::LayoutContext; ...
} if opts::get().bubble_inline_sizes_separately { let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context, }; bubble_inline_sizes.traverse(root); } let assign_inline_sizes = AssignISizes { layout_context: &layout_context, }; let ass...
{ assign_block_sizes.process(flow); }
conditional_block
sequential.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/. */ //! Implements sequential traversals over the DOM and flow trees. use app_units::Au; use context::LayoutContext; ...
/// Run the main layout passes sequentially. pub fn reflow(root: &mut Flow, layout_context: &LayoutContext, relayout_mode: RelayoutMode) { fn doit(flow: &mut Flow, assign_inline_sizes: AssignISizes, assign_block_sizes: AssignBSizes, relayout_mode: RelayoutMode) { // For...
{ ResolveGeneratedContent::new(&layout_context).traverse(root, 0); }
identifier_body
sequential.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/. */ //! Implements sequential traversals over the DOM and flow trees. use app_units::Au; use context::LayoutContext; ...
(root: &mut Flow, layout_context: &LayoutContext, relayout_mode: RelayoutMode) { fn doit(flow: &mut Flow, assign_inline_sizes: AssignISizes, assign_block_sizes: AssignBSizes, relayout_mode: RelayoutMode) { // Force reflow children during this traversal. This is needed whe...
reflow
identifier_name
dxgi1_3.rs
// Copyright © 2015-2017 winapi-rs developers // 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 not be copied,...
fn SetColorSpace( ColorSpace: DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS, ) -> HRESULT, fn GetColorSpace() -> DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS, }); extern "system" { pub fn CreateDXGIFactory2( Flags: UINT, riid: REFIID, ppFactory: *mut *mut c_void, ) -> HRESULT; pub f...
random_line_split
trait-safety-ok-cc.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. //
// aux-build:trait_safety_lib.rs // Simple smoke test that unsafe traits can be compiled across crates. extern crate trait_safety_lib as lib; use lib::Foo; struct Bar { x: isize } unsafe impl Foo for Bar { fn foo(&self) -> isize { self.x } } fn take_foo<F:Foo>(f: &F) -> isize { f.foo() } fn main() { let...
// 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
trait-safety-ok-cc.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 ...
{ x: isize } unsafe impl Foo for Bar { fn foo(&self) -> isize { self.x } } fn take_foo<F:Foo>(f: &F) -> isize { f.foo() } fn main() { let x: isize = 22; assert_eq!(22, take_foo(&x)); let x: Bar = Bar { x: 23 }; assert_eq!(23, take_foo(&x)); }
Bar
identifier_name
trait-safety-ok-cc.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: isize = 22; assert_eq!(22, take_foo(&x)); let x: Bar = Bar { x: 23 }; assert_eq!(23, take_foo(&x)); }
identifier_body
overloaded-autoderef-vtable.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 main() { let x: DerefWithHelper<Option<Foo>, Foo> = DerefWithHelper { helper: Some(Foo {x: 5}), value: Foo { x: 2 } }; assert_eq!(x.foo(), 5); }
impl Foo { fn foo(&self) -> isize {self.x}
random_line_split
overloaded-autoderef-vtable.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 ...
{x: isize} impl Foo { fn foo(&self) -> isize {self.x} } pub fn main() { let x: DerefWithHelper<Option<Foo>, Foo> = DerefWithHelper { helper: Some(Foo {x: 5}), value: Foo { x: 2 } }; assert_eq!(x.foo(), 5); }
Foo
identifier_name
oesvertexarrayobject.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::CanvasMsg; use dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::{self, OESVertexA...
// Unbind deleted VAO if currently bound if let Some(bound_vao) = self.bound_vao.get() { if bound_vao.id() == vao.id() { self.bound_vao.set(None); self.ctx.send_renderer_message(CanvasMsg::WebGL(WebGLCommand::BindVertexArray(None))); ...
{ return; }
conditional_block
oesvertexarrayobject.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::CanvasMsg; use dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::{self, OESVertexA...
fn is_supported(ext: &WebGLExtensions) -> bool { ext.supports_any_gl_extension(&["GL_OES_vertex_array_object", "GL_ARB_vertex_array_object", "GL_APPLE_vertex_array_object"]) } fn enable(ext: &WebGLExtensions) { ...
{ reflect_dom_object(box OESVertexArrayObject::new_inherited(ctx), &*ctx.global(), OESVertexArrayObjectBinding::Wrap) }
identifier_body
oesvertexarrayobject.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::CanvasMsg; use dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::{self, OESVertexArrayObjectMethods}; use dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants; use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObje...
random_line_split
oesvertexarrayobject.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::CanvasMsg; use dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::{self, OESVertexA...
() -> &'static str { "OES_vertex_array_object" } }
name
identifier_name
unwind-box-res.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 ...
{ unsafe { let i1 = box 0; let i1p = cast::transmute_copy(&i1); cast::forget(i1); let x = @r(i1p); failfn(); println!("{:?}", x); } }
identifier_body
unwind-box-res.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { unsafe { let i1 = box 0; let i1p = cast::transmute_copy(&i1); cast::forget(i1); let x = @r(i1p); failfn(); println!("{:?}", x); } }
random_line_split
unwind-box-res.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 ...
() { unsafe { let i1 = box 0; let i1p = cast::transmute_copy(&i1); cast::forget(i1); let x = @r(i1p); failfn(); println!("{:?}", x); } }
main
identifier_name
placeholder.rs
use std::rc; use time; use serialize::json; use super::expression; use super::sql; #[derive(Clone, Copy)] pub struct Placeholder { idx: u8 } impl Placeholder { pub fn new(idx: u8) -> Placeholder { Placeholder { idx: idx } } pub fn get_idx(&self) -> u8 { self.idx } } impl express...
} impl expression::ToExpression<bool> for Placeholder {} impl expression::ToExpression<f64> for Placeholder {} impl expression::ToExpression<String> for Placeholder {} impl expression::ToExpression<Vec<u8>> for Placeholder {} impl expression::ToExpression<time::Timespec> for Placeholder {} impl expression::ToExpressi...
{ rc::Rc::new(Box::new(self.clone()) as expression::BoxedExpression) }
identifier_body
placeholder.rs
use std::rc; use time; use serialize::json; use super::expression; use super::sql; #[derive(Clone, Copy)]
} impl Placeholder { pub fn new(idx: u8) -> Placeholder { Placeholder { idx: idx } } pub fn get_idx(&self) -> u8 { self.idx } } impl expression::UntypedExpression for Placeholder { fn expression_as_sql(&self) -> &sql::ToSql { self } fn upcast_expression(&self) -> ...
pub struct Placeholder { idx: u8
random_line_split
placeholder.rs
use std::rc; use time; use serialize::json; use super::expression; use super::sql; #[derive(Clone, Copy)] pub struct Placeholder { idx: u8 } impl Placeholder { pub fn new(idx: u8) -> Placeholder { Placeholder { idx: idx } } pub fn get_idx(&self) -> u8 { self.idx } } impl express...
(&self) -> expression::SharedExpression { rc::Rc::new(Box::new(self.clone()) as expression::BoxedExpression) } } impl expression::ToExpression<bool> for Placeholder {} impl expression::ToExpression<f64> for Placeholder {} impl expression::ToExpression<String> for Placeholder {} impl expression::ToExpressio...
upcast_expression
identifier_name
bpf.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.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
extern crate libc; use std::collections::VecDeque; use std::cmp; use std::ffi::CString; use std::io; use std::iter::repeat; use std::mem; use std::sync::Arc; use bindings::bpf; use packet::Packet; use packet::ethernet::{EthernetPacket, MutableEthernetPacket}; use datalink::DataLinkChannelType; use datalink::DataLink...
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
bpf.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.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. This file may not be copied, modifi...
{ fd: Arc<internal::FileDesc>, read_buffer: Vec<u8>, header_size: usize, } impl DataLinkReceiverImpl { pub fn iter<'a>(&'a mut self) -> DataLinkChannelIteratorImpl<'a> { let buflen = self.read_buffer.len(); DataLinkChannelIteratorImpl { pc: self, // Enough room ...
DataLinkReceiverImpl
identifier_name
rpcndr.rs
// Copyright © 2016-2017 winapi-rs developers // 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 not be copied,...
// TODO Finish the rest
pub type byte = c_uchar; pub type cs_byte = byte; pub type boolean = c_uchar; pub type hyper = __int64; pub type MIDL_uhyper = __uint64;
random_line_split
main.rs
#![feature(globs)] //Enable experimental glob import extern crate native; extern crate gl; extern crate glfw; use gl::types::*; use glfw::Context; use std::mem; use std::ptr; use std::str; static VERTEX_DATA: [GLfloat,..12] = [ -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, -0.5 ...
(window: &glfw::Window, event: glfw::WindowEvent) { match event { glfw::KeyEvent(glfw::KeyEscape, _, glfw::Press, _) => { window.set_should_close(true) } _ => {} } }
handle_window_event
identifier_name
main.rs
#![feature(globs)] //Enable experimental glob import extern crate native; extern crate gl; extern crate glfw; use gl::types::*; use glfw::Context; use std::mem; use std::ptr; use std::str; static VERTEX_DATA: [GLfloat,..12] = [ -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, -0.5 ...
gl::ActiveTexture(gl::TEXTURE0); gl::BindTexture(gl::TEXTURE_2D, //TODO... finish this! // Use shader program gl::UseProgram(program); "out_color".with_c_str(|ptr| gl::BindFragDataLocation(program, 0, ptr)); // Specify the layout of the vertex data let ...
gl::STATIC_DRAW);
random_line_split
main.rs
#![feature(globs)] //Enable experimental glob import extern crate native; extern crate gl; extern crate glfw; use gl::types::*; use glfw::Context; use std::mem; use std::ptr; use std::str; static VERTEX_DATA: [GLfloat,..12] = [ -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, -0.5 ...
} program } #[start] fn start(argc: int, argv: *const *const u8) -> int { native::start(argc, argv, main) } fn main() { println!("Hello, world!") let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap(); glfw.window_hint(glfw::ContextVersion(3,2)); glfw.window_hint(glfw::OpenglForwardC...
{ let mut len: GLint = 0; gl::GetProgramiv(program, gl::INFO_LOG_LENGTH, &mut len); let mut buf = Vec::from_elem(len as uint - 1, 0u8); // subtract 1 to skip the trailing null character gl::GetProgramInfoLog(program, len, ptr::null_mut(), buf.as_mut_ptr() as *mut GLch...
conditional_block
main.rs
#![feature(globs)] //Enable experimental glob import extern crate native; extern crate gl; extern crate glfw; use gl::types::*; use glfw::Context; use std::mem; use std::ptr; use std::str; static VERTEX_DATA: [GLfloat,..12] = [ -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, -0.5 ...
shader } fn link_program(vs: GLuint, fs: GLuint) -> GLuint { let program = gl::CreateProgram(); gl::AttachShader(program, vs); gl::AttachShader(program, fs); gl::LinkProgram(program); unsafe { // Get the link status let mut status = gl::FALSE as GLint; gl::GetProgramiv(...
{ let shader = gl::CreateShader(ty); unsafe { // Attempt to compile the shader src.with_c_str(|ptr| gl::ShaderSource(shader, 1, &ptr, ptr::null())); gl::CompileShader(shader); // Get the compile status let mut status = gl::FALSE as GLint; gl::GetShaderiv(shader, ...
identifier_body
arc_hybrid.rs
use std::collections::HashMap; use serde_derive::{Deserialize, Serialize}; use crate::guide::Guide; use crate::system::{ Dependency, DependencySet, ParserState, Transition, TransitionLookup, TransitionSystem, }; use crate::features::addr::Source; use crate::system::AttachmentAddr; use crate::systems::util::dep_h...
(state: &ParserState<'_>) -> bool { state.buffer().is_empty() && state.stack().len() == 1 } fn oracle(gold_dependencies: &DependencySet) -> Self::Oracle { ArcHybridOracle::new(gold_dependencies) } fn transitions(&self) -> &TransitionLookup<Self::Transition> { &self.transitions ...
is_terminal
identifier_name
arc_hybrid.rs
use std::collections::HashMap; use serde_derive::{Deserialize, Serialize}; use crate::guide::Guide; use crate::system::{ Dependency, DependencySet, ParserState, Transition, TransitionLookup, TransitionSystem, }; use crate::features::addr::Source; use crate::system::AttachmentAddr; use crate::systems::util::dep_h...
} impl TransitionSystem for ArcHybridSystem { type Transition = ArcHybridTransition; type Oracle = ArcHybridOracle; const ATTACHMENT_ADDRS: [AttachmentAddr; 2] = [ AttachmentAddr { head: Source::Buffer(0), dependent: Source::Stack(0), }, AttachmentAddr { ...
{ ArcHybridSystem::new() }
identifier_body
arc_hybrid.rs
use std::collections::HashMap; use serde_derive::{Deserialize, Serialize}; use crate::guide::Guide; use crate::system::{ Dependency, DependencySet, ParserState, Transition, TransitionLookup, TransitionSystem, }; use crate::features::addr::Source; use crate::system::AttachmentAddr; use crate::systems::util::dep_h...
state.add_dependency(Dependency { head, relation: rel.clone(), dependent, }); state.stack_mut().pop(); } ArcHybridTransition::Shift => { let next = state.buffer_mut().rem...
} ArcHybridTransition::RightArc(ref rel) => { let dependent = state.stack()[stack_len - 1]; let head = state.stack()[stack_len - 2];
random_line_split
arc_hybrid.rs
use std::collections::HashMap; use serde_derive::{Deserialize, Serialize}; use crate::guide::Guide; use crate::system::{ Dependency, DependencySet, ParserState, Transition, TransitionLookup, TransitionSystem, }; use crate::features::addr::Source; use crate::system::AttachmentAddr; use crate::systems::util::dep_h...
} ArcHybridTransition::Shift } }
{ let ra = ArcHybridTransition::RightArc(dep.relation.clone()); if dep.head == stack1 && ra.is_possible(state) && !self.needed_for_attachment(state, stack0) { return ra; } }
conditional_block
shootout-nbody.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2011-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
(bodies: &mut [Planet;N_BODIES]) { let mut px = 0.0; let mut py = 0.0; let mut pz = 0.0; for bi in bodies.iter() { px += bi.vx * bi.mass; py += bi.vy * bi.mass; pz += bi.vz * bi.mass; } let sun = &mut bodies[0]; sun.vx = - px / SOLAR_MASS; sun.vy = - py / SOLAR_MA...
offset_momentum
identifier_name
shootout-nbody.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2011-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
fn offset_momentum(bodies: &mut [Planet;N_BODIES]) { let mut px = 0.0; let mut py = 0.0; let mut pz = 0.0; for bi in bodies.iter() { px += bi.vx * bi.mass; py += bi.vy * bi.mass; pz += bi.vz * bi.mass; } let sun = &mut bodies[0]; sun.vx = - px / SOLAR_MASS; sun....
{ let mut e = 0.0; let mut bodies = bodies.iter(); loop { let bi = match bodies.next() { Some(bi) => bi, None => break }; e += (bi.vx * bi.vx + bi.vy * bi.vy + bi.vz * bi.vz) * bi.mass / 2.0; for bj in bodies.clone() { let dx = bi.x - bj.x;...
identifier_body
shootout-nbody.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2011-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
}, // Jupiter Planet { x: 4.84143144246472090e+00, y: -1.16032004402742839e+00, z: -1.03622044471123109e-01, vx: 1.66007664274403694e-03 * YEAR, vy: 7.69901118419740425e-03 * YEAR, vz: -6.90460016972063023e-05 * YEAR, mass: 9.54791938424326609e-04 * SO...
Planet { x: 0.0, y: 0.0, z: 0.0, vx: 0.0, vy: 0.0, vz: 0.0, mass: SOLAR_MASS,
random_line_split
main.rs
#[macro_use] extern crate serde_derive; use std::collections::VecDeque; use std::env; use std::fs::File; use std::io::{BufReader, Read}; use std::sync::{Arc, Mutex}; use std::thread::{self, sleep}; use std::time::Duration; use std::time::{SystemTime, UNIX_EPOCH}; use async_h1::client; use async_std::net::{TcpListener...
let mut deserializer = Deserializer::from_slice(&buffer); // Guard: can't be parsed let rpc_req: RPCRequest = match RPCRequest::deserialize(&mut deserializer) { Ok(rpc_req) => rpc_req, _ => return Ok(Response::new(StatusCode::Meth...
{ async_h1::accept(&addr, stream.clone(), |mut req| async { match ( req.method(), req.url().path(), req.header(&headers::CONTENT_TYPE), ) { (Method::Get, "/ping", Some(_content_type)) => Ok(Response::new(StatusCode::Ok)), (Method::Post, "/"...
identifier_body
main.rs
#[macro_use] extern crate serde_derive; use std::collections::VecDeque; use std::env; use std::fs::File; use std::io::{BufReader, Read}; use std::sync::{Arc, Mutex}; use std::thread::{self, sleep}; use std::time::Duration; use std::time::{SystemTime, UNIX_EPOCH}; use async_h1::client; use async_std::net::{TcpListener...
(&self, block_height: u64) -> bool { match self.get_blocks_config_at_height(block_height) { Some(conf) => conf.ignore_txs, None => false, } } pub fn get_block_time_at_height(&self, block_height: u64) -> u64 { match self.get_blocks_config_at_height(block_height) {...
should_ignore_transactions
identifier_name
main.rs
#[macro_use] extern crate serde_derive; use std::collections::VecDeque; use std::env; use std::fs::File; use std::io::{BufReader, Read}; use std::sync::{Arc, Mutex}; use std::thread::{self, sleep}; use std::time::Duration; use std::time::{SystemTime, UNIX_EPOCH}; use async_h1::client; use async_std::net::{TcpListener...
now.clone() } else { match std::env::var("STATIC_GENESIS_TIMESTAMP") { Ok(val) => match val.parse::<u64>() { Ok(val) => val, Err(err) => { println!("WARN: parsing STATIC_GENESIS_TIMESTAMP failed ({:?}), falli...
println!( "INFO: detected DYNAMIC_GENESIS_TIMESTAMP, will set the genesis timestamp to {}", now );
random_line_split
main.rs
#[macro_use] extern crate serde_derive; use std::collections::VecDeque; use std::env; use std::fs::File; use std::io::{BufReader, Read}; use std::sync::{Arc, Mutex}; use std::thread::{self, sleep}; use std::time::Duration; use std::time::{SystemTime, UNIX_EPOCH}; use async_h1::client; use async_std::net::{TcpListener...
}; } fn build_request(config: &ConfigFile, body: Vec<u8>) -> Request { let url = Url::parse(&format!("http://{}/", config.network.bitcoind_rpc_host)).unwrap(); let mut req = Request::new(Method::Post, url); req.append_header("Authorization", config.network.authorization_token()) .unwrap(); ...
{ println!("ERROR: rpc invokation failed - {:?}", err); return; }
conditional_block
resource_thread.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/. */ //! A thread that takes a URL and streams back the binary data. use connector::{create_http_connector, create_ssl_...
self.resource_manager.cancel_load_map.remove(&res_id); } CoreResourceMsg::Synchronize(sender) => { let _ = sender.send(()); } CoreResourceMsg::ToFileManager(msg) => self.resource_manager.filemanager.handle(msg, TFD_PROVIDER), Co...
if let Some(cancel_sender) = self.resource_manager.cancel_load_map.get(&res_id) { let _ = cancel_sender.send(()); }
random_line_split
resource_thread.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/. */ //! A thread that takes a URL and streams back the binary data. use connector::{create_http_connector, create_ssl_...
{ pub version: u32, pub entries: HashMap<String, AuthCacheEntry>, } pub struct CoreResourceManager { user_agent: Cow<'static, str>, devtools_chan: Option<Sender<DevtoolsControlMsg>>, swmanager_chan: Option<IpcSender<CustomResponseMediator>>, filemanager: FileManager, cancel_load_map: HashM...
AuthCache
identifier_name
font_context.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::rc::Rc; extern mod freetype; extern mod fontconfig; use self::freetype::freetype::{ FTErrorMethods,...
}
{ debug!("Creating font handle for {:s}", name); do path_from_identifier(name).chain |file_name| { debug!("Opening font face {:s}", file_name); FreeTypeFontHandle::new_from_file(self, file_name, &style) } }
identifier_body
font_context.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::rc::Rc; extern mod freetype; extern mod fontconfig; use self::freetype::freetype::{ FTErrorMethods,...
{ ctx: FT_Library, } impl Drop for FreeTypeLibraryHandle { fn finalize(&self) { assert!(self.ctx.is_not_null()); FT_Done_FreeType(self.ctx); } } pub struct FreeTypeFontContextHandle { ctx: Rc<FreeTypeLibraryHandle>, } pub impl FreeTypeFontContextHandle { pub fn new() -> FreeTypeF...
FreeTypeLibraryHandle
identifier_name
font_context.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::rc::Rc; extern mod freetype; extern mod fontconfig; use self::freetype::freetype::{ FTErrorMethods,...
FreeTypeFontContextHandle { ctx: Rc::new(FreeTypeLibraryHandle { ctx: ctx }), } } } impl FontContextHandleMethods for FreeTypeFontContextHandle { fn clone(&self) -> FreeTypeFontContextHandle { FreeTypeFontContextHandle { ctx: self.ctx } } fn create_font_from_ident...
{ fail!(); }
conditional_block
font_context.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::rc::Rc; extern mod freetype; extern mod fontconfig; use self::freetype::freetype::{ FTErrorMethods,...
impl Drop for FreeTypeLibraryHandle { fn finalize(&self) { assert!(self.ctx.is_not_null()); FT_Done_FreeType(self.ctx); } } pub struct FreeTypeFontContextHandle { ctx: Rc<FreeTypeLibraryHandle>, } pub impl FreeTypeFontContextHandle { pub fn new() -> FreeTypeFontContextHandle { ...
struct FreeTypeLibraryHandle { ctx: FT_Library, }
random_line_split
stores.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ // CHECK: [[VAR:%[0-9]+]] = load %Bytes** %x // CHECK: [[VAR2:%[0-9]+]] = bitcast %Bytes* [[VAR]] to i32* // CHECK: store i32 %{{.*}}, i32* [[VAR2]], align 1 *x = Bytes { a: 0, b: 0, c: 0, d: 0, }; }
identifier_body
stores.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(x: &mut [i8; 4]) { // CHECK: [[VAR:%[0-9]+]] = load [4 x i8]** %x // CHECK: [[VAR2:%[0-9]+]] = bitcast [4 x i8]* [[VAR]] to i32* // CHECK: store i32 %{{.*}}, i32* [[VAR2]], align 1 *x = [0; 4]; } // CHECK-LABEL: small_struct_alignment // The struct is stored as i32, but its alignment is lower, go with 1 byte to a...
small_array_alignment
identifier_name
stores.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// dependent alignment #[no_mangle] pub fn small_struct_alignment(x: &mut Bytes) { // CHECK: [[VAR:%[0-9]+]] = load %Bytes** %x // CHECK: [[VAR2:%[0-9]+]] = bitcast %Bytes* [[VAR]] to i32* // CHECK: store i32 %{{.*}}, i32* [[VAR2]], align 1 *x = Bytes { a: 0, b: 0, c: 0, d: 0, };...
// CHECK-LABEL: small_struct_alignment // The struct is stored as i32, but its alignment is lower, go with 1 byte to avoid target
random_line_split
lifetime.rs
// run-pass // ignore-compare-mode-nll #![feature(trait_upcasting)] #![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 } fn z(&self) -> i32 { 11 } fn y(&self) -> i32 { 12 } } trait Bar: Foo { fn b(&s...
}
let foo: Box<dyn Foo> = bar; let u = upcast_foo(foo, &l); assert_eq!(*u, 1); assert_eq!(u.a(), 100);
random_line_split
lifetime.rs
// run-pass // ignore-compare-mode-nll #![feature(trait_upcasting)] #![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 } fn z(&self) -> i32 { 11 } fn y(&self) -> i32 { 12 } } trait Bar: Foo { fn b(&s...
} trait Baz: Bar { fn c(&self) -> i32 { 30 } } impl Foo for i32 { fn a(&self) -> i32 { 100 } } impl Bar for i32 { fn b(&self) -> i32 { 200 } } impl Baz for i32 { fn c(&self) -> i32 { 300 } } // Note: upcast lifetime means a shorter lifetime. fn upcas...
{ 21 }
identifier_body
lifetime.rs
// run-pass // ignore-compare-mode-nll #![feature(trait_upcasting)] #![allow(incomplete_features)] trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 } fn z(&self) -> i32 { 11 } fn y(&self) -> i32 { 12 } } trait Bar: Foo { fn b(&s...
(&self) -> i32 { 30 } } impl Foo for i32 { fn a(&self) -> i32 { 100 } } impl Bar for i32 { fn b(&self) -> i32 { 200 } } impl Baz for i32 { fn c(&self) -> i32 { 300 } } // Note: upcast lifetime means a shorter lifetime. fn upcast_baz<'a: 'b, 'b, T>(v: Box<d...
c
identifier_name
unsized5.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 main() { }
random_line_split
unsized5.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 ...
<X:?Sized> { f: int, g: X, //~ ERROR `core::marker::Sized` is not implemented h: int, } struct S3 { f: str, //~ ERROR `core::marker::Sized` is not implemented g: [uint] } struct S4 { f: str, //~ ERROR `core::marker::Sized` is not implemented g: uint } enum E<X:?Sized> { V1(X, int), //~ER...
S2
identifier_name
runtime.rs
use super::super::namespace::InvokeContext; use wasm_core::value::Value; decl_namespace!( RuntimeNs, "runtime", RuntimeImpl, spec_major, spec_minor, name ); pub struct RuntimeImpl; impl RuntimeImpl { pub fn spec_major(&self, _: InvokeContext) -> Option<Value> { Some(Value::I32(sup...
} }
} out[0..name.len()].copy_from_slice(name); Some(Value::I32(name.len() as i32))
random_line_split
runtime.rs
use super::super::namespace::InvokeContext; use wasm_core::value::Value; decl_namespace!( RuntimeNs, "runtime", RuntimeImpl, spec_major, spec_minor, name ); pub struct RuntimeImpl; impl RuntimeImpl { pub fn spec_major(&self, _: InvokeContext) -> Option<Value> { Some(Value::I32(sup...
out[0..name.len()].copy_from_slice(name); Some(Value::I32(name.len() as i32)) } }
{ return Some(Value::I32(super::ErrorCode::InvalidArgumentError.into())); }
conditional_block
runtime.rs
use super::super::namespace::InvokeContext; use wasm_core::value::Value; decl_namespace!( RuntimeNs, "runtime", RuntimeImpl, spec_major, spec_minor, name ); pub struct RuntimeImpl; impl RuntimeImpl { pub fn spec_major(&self, _: InvokeContext) -> Option<Value> { Some(Value::I32(sup...
(&self, _: InvokeContext) -> Option<Value> { Some(Value::I32(super::MINOR_VERSION)) } pub fn name(&self, mut ctx: InvokeContext) -> Option<Value> { let out = ctx.extract_bytes_mut(0, 1); let name = "Ice".as_bytes(); if out.len() < name.len() { return Some(Value::I32...
spec_minor
identifier_name
geometry.rs
//! Computational geometry functions, for example finding convex hulls. use crate::point::{distance, Line, Point, Rotation}; use num::{cast, NumCast}; use std::cmp::{Ord, Ordering}; use std::f64::{self, consts::PI}; /// Computes the length of an arc. If `closed` is set to `true` then the distance /// between the last...
start_point.to_i32(), p.to_i32(), iter.peek().unwrap().to_i32(), ) == Orientation::Collinear { p = iter.next().unwrap(); } remaining_points.push(p); } let mut stack: Vec<Point<T>> = vec![Point::new( cast(sta...
let mut remaining_points = Vec::with_capacity(points.len()); while let Some(mut p) = iter.next() { while iter.peek().is_some() && orientation(
random_line_split
geometry.rs
//! Computational geometry functions, for example finding convex hulls. use crate::point::{distance, Line, Point, Rotation}; use num::{cast, NumCast}; use std::cmp::{Ord, Ordering}; use std::f64::{self, consts::PI}; /// Computes the length of an arc. If `closed` is set to `true` then the distance /// between the last...
e { 0 }; [ Point::new( cast(res[i1].x.floor()).unwrap(), cast(res[i1].y.floor()).unwrap(), ), Point::new( cast(res[i2].x.ceil()).unwrap(), cast(res[i2].y.floor()).unwrap(), ), Point::new( cast(res[i3].x.ceil()).unwr...
} els
conditional_block
geometry.rs
//! Computational geometry functions, for example finding convex hulls. use crate::point::{distance, Line, Point, Rotation}; use num::{cast, NumCast}; use std::cmp::{Ord, Ordering}; use std::f64::{self, consts::PI}; /// Computes the length of an arc. If `closed` is set to `true` then the distance /// between the last...
Collinear, Clockwise, CounterClockwise, } /// Determines whether p -> q -> r is a left turn, a right turn, or the points are collinear. fn orientation(p: Point<i32>, q: Point<i32>, r: Point<i32>) -> Orientation { let val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); match val.cmp(&0) { ...
ntation {
identifier_name
geometry.rs
//! Computational geometry functions, for example finding convex hulls. use crate::point::{distance, Line, Point, Rotation}; use num::{cast, NumCast}; use std::cmp::{Ord, Ordering}; use std::f64::{self, consts::PI}; /// Computes the length of an arc. If `closed` is set to `true` then the distance /// between the last...
Point::new(60, 25) ] ); } #[test] fn convex_hull_points_empty_vec() { let points = convex_hull::<i32>(&vec![]); assert_eq!(points, []); } #[test] fn convex_hull_points_with_negative_values() { let star = vec![ Point::new(...
let star = vec![ Point::new(100, 20), Point::new(90, 35), Point::new(60, 25), Point::new(90, 40), Point::new(80, 55), Point::new(101, 50), Point::new(130, 60), Point::new(115, 45), Point::new(140, 30), ...
identifier_body
config.rs
#[derive(Serialize, Deserialize, Debug)] pub enum Action { Move, Link, } #[derive(Serialize, Deserialize, Debug)] pub struct Match { pub regex: String, pub destination: String, pub action: Action, } #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub skipextension: String, pub...
}); c.matches.push(Match { regex: "*Big.Bang*".to_owned(), destination: "/mainpool/shared/shows/The.big.bang.theory".to_owned(), action: Action::Link, }); let s = serde_json::to_string(&c).unwrap(); println!("{}", s); let c2: Config = serde_json::from_str(&s).unwrap(...
action: Action::Move,
random_line_split
config.rs
#[derive(Serialize, Deserialize, Debug)] pub enum Action { Move, Link, } #[derive(Serialize, Deserialize, Debug)] pub struct Match { pub regex: String, pub destination: String, pub action: Action, } #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub skipextension: String, pub...
(regex: &str, destination: &str, action: Action) -> Match { Match { regex: regex.to_owned(), destination: destination.to_owned(), action: action, } } } #[test] fn test_serialize_deserialize() { use serde_json; let mut c = Config::new("tormed"); c.ma...
new
identifier_name
bpf.rs
// Copyright (c) 2014 Robert Clipsham <robert@octarineparrot.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. This file may not be copied, modified, or...
{ pub tv_sec: i32, pub tv_usec: i32, } #[cfg(all(target_os = "macos", target_pointer_width = "64"))] pub struct bpf_hdr { pub bh_tstamp: timeval32, pub bh_caplen: u32, pub bh_datalen: u32, pub bh_hdrlen: libc::c_ushort, } #[cfg(not(windows))] extern { pub fn ioctl(d: libc::c_int, request:...
timeval32
identifier_name
bpf.rs
// Copyright (c) 2014 Robert Clipsham <robert@octarineparrot.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. This file may not be copied, modified, or...
// sdl_data does not match if_dl.h on OS X, since the size of 12 is a minimum. // Will be unsafe // when sdl_nlen > 40. #[cfg(any(target_os = "freebsd", target_os = "macos"))] pub struct sockaddr_dl { pub sdl_len: libc::c_uchar, pub sdl_family: libc::c_uchar, pub sdl_index: libc::c_ushort, pub sdl_type:...
// See /usr/include/net/if_dl.h
random_line_split
app_uart_tiva_c.rs
#![feature(plugin)] #![crate_type="staticlib"] #![no_std] extern crate core; extern crate zinc; #[macro_use] #[plugin] #[no_link] extern crate macro_platformtree; use zinc::drivers::chario::CharIO; platformtree!( tiva_c@mcu { clock { source = "MOSC"; xtal = "X16_0MHz"; pll = true; ...
(args: &pt::run_args) { use zinc::hal::timer::Timer; use zinc::hal::pin::Gpio; args.uart.puts("Hello, world\r\n"); let mut i = 0; loop { args.txled.set_high(); args.uart.puts("Waiting for "); args.uart.puti(i); args.uart.puts(" seconds...\r\n"); i += 1; args.txled.set_low(); ar...
run
identifier_name
app_uart_tiva_c.rs
#![feature(plugin)] #![crate_type="staticlib"] #![no_std] extern crate core; extern crate zinc; #[macro_use] #[plugin] #[no_link] extern crate macro_platformtree; use zinc::drivers::chario::CharIO; platformtree!( tiva_c@mcu { clock { source = "MOSC"; xtal = "X16_0MHz"; pll = true; ...
{ use zinc::hal::timer::Timer; use zinc::hal::pin::Gpio; args.uart.puts("Hello, world\r\n"); let mut i = 0; loop { args.txled.set_high(); args.uart.puts("Waiting for "); args.uart.puti(i); args.uart.puts(" seconds...\r\n"); i += 1; args.txled.set_low(); args.timer.wait(1); } ...
identifier_body