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
dompoint.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{ DOMPointInit, DOMPointMethods, Wrap, }; use c...
} } impl DOMPointMethods for DOMPoint { // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x fn X(&self) -> f64 { self.point.X() } // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x fn SetX(&self, value: f64) { self.point.SetX(value); ...
} pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> DomRoot<DOMPoint> { DOMPoint::new(global, p.x, p.y, p.z, p.w)
random_line_split
dompoint.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{ DOMPointInit, DOMPointMethods, Wrap, }; use c...
} impl DOMPointMethods for DOMPoint { // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x fn X(&self) -> f64 { self.point.X() } // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x fn SetX(&self, value: f64) { self.point.SetX(value); } ...
{ DOMPoint::new(global, p.x, p.y, p.z, p.w) }
identifier_body
terminal.rs
//! Functions related to terminal devices. use std::{mem, ptr}; use libc::{c_int, c_void}; use remacs_macros::lisp_fn; use crate::{ dispnew::LispGlyphRef, frames::Fselected_frame, frames::LispFrameRef, lisp::{ExternalPtr, LispObject}, remacs_sys::build_string, remacs_sys::{pvec_type, Lisp_Te...
} /// Insert LEN glyphs from START at the nominal cursor position. /// /// If start is zero, insert blanks instead of a string at start #[no_mangle] pub unsafe extern "C" fn insert_glyphs(mut f: LispFrameRef, mut start: LispGlyphRef, len: c_int) { if len <= 0 { return; } if let Some(hook) = (*f.ter...
random_line_split
terminal.rs
//! Functions related to terminal devices. use std::{mem, ptr}; use libc::{c_int, c_void}; use remacs_macros::lisp_fn; use crate::{ dispnew::LispGlyphRef, frames::Fselected_frame, frames::LispFrameRef, lisp::{ExternalPtr, LispObject}, remacs_sys::build_string, remacs_sys::{pvec_type, Lisp_Te...
/// Clear entire frame. #[no_mangle] pub unsafe extern "C" fn clear_frame(mut f: LispFrameRef) { if let Some(hook) = (*f.terminal).clear_frame_hook { hook(f.as_mut()) } } /// Clear from cursor to end of line. /// Assume that the line is already clear starting at column first_unused_hpos. /// /// Note...
{ if let Some(hook) = (*f.terminal).clear_to_end_hook { hook(f.as_mut()) } }
identifier_body
terminal.rs
//! Functions related to terminal devices. use std::{mem, ptr}; use libc::{c_int, c_void}; use remacs_macros::lisp_fn; use crate::{ dispnew::LispGlyphRef, frames::Fselected_frame, frames::LispFrameRef, lisp::{ExternalPtr, LispObject}, remacs_sys::build_string, remacs_sys::{pvec_type, Lisp_Te...
} /// Delete N glyphs at the nominal cursor position. #[no_mangle] pub unsafe extern "C" fn delete_glyphs(mut f: LispFrameRef, n: c_int) { if let Some(hook) = (*f.terminal).delete_glyphs_hook { hook(f.as_mut(), n) } } /// Insert N lines at vpos VPOS. If N is negative, delete -N lines. #[no_mangle] p...
{ hook(f.as_mut(), start.as_mut(), len) }
conditional_block
terminal.rs
//! Functions related to terminal devices. use std::{mem, ptr}; use libc::{c_int, c_void}; use remacs_macros::lisp_fn; use crate::{ dispnew::LispGlyphRef, frames::Fselected_frame, frames::LispFrameRef, lisp::{ExternalPtr, LispObject}, remacs_sys::build_string, remacs_sys::{pvec_type, Lisp_Te...
(mut f: LispFrameRef) { if let Some(hook) = (*f.terminal).update_begin_hook { hook(f.as_mut()) } } #[no_mangle] pub unsafe extern "C" fn update_end(mut f: LispFrameRef) { if let Some(hook) = (*f.terminal).update_end_hook { hook(f.as_mut()) } } // Erase operations. /// Clear from curso...
update_begin
identifier_name
prefab.rs
use crayon::errors::*; use crayon::res::utils::prelude::ResourceState; use crayon::sched::prelude::LatchProbe; use crayon::uuid::Uuid; use crayon::video::assets::mesh::MeshHandle; use spatial::prelude::Transform; impl_handle!(PrefabHandle); /// A prefab asset acts as a template from which you can create new /// enti...
fn is_set(&self) -> bool { ResourceState::NotReady!= crate::prefab_state(*self) } }
impl LatchProbe for PrefabHandle {
random_line_split
prefab.rs
use crayon::errors::*; use crayon::res::utils::prelude::ResourceState; use crayon::sched::prelude::LatchProbe; use crayon::uuid::Uuid; use crayon::video::assets::mesh::MeshHandle; use spatial::prelude::Transform; impl_handle!(PrefabHandle); /// A prefab asset acts as a template from which you can create new /// enti...
}
{ ResourceState::NotReady != crate::prefab_state(*self) }
identifier_body
prefab.rs
use crayon::errors::*; use crayon::res::utils::prelude::ResourceState; use crayon::sched::prelude::LatchProbe; use crayon::uuid::Uuid; use crayon::video::assets::mesh::MeshHandle; use spatial::prelude::Transform; impl_handle!(PrefabHandle); /// A prefab asset acts as a template from which you can create new /// enti...
{ /// The mesh index. pub mesh: usize, /// Indicates whether this object cast shadows. pub shadow_caster: bool, /// Indicates whether this object receive shadows. pub shadow_receiver: bool, /// Is this renderer visible. pub visible: bool, } impl Prefab { pub fn validate(&self) -> R...
PrefabMeshRenderer
identifier_name
effect.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
ty::ty_bare_fn(ref f) => f.purity == ast::unsafe_fn, ty::ty_closure(ref f) => f.purity == ast::unsafe_fn, _ => false, } } struct EffectCheckVisitor { tcx: ty::ctxt, /// The method map. method_map: method_map, /// Whether we're in an unsafe context. unsafe_context: Unsaf...
UnsafeBlock(ast::NodeId), } fn type_is_unsafe_function(ty: ty::t) -> bool { match ty::get(ty).sty {
random_line_split
effect.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(tcx: ty::ctxt, method_map: method_map, crate: &ast::Crate) { let mut visitor = EffectCheckVisitor { tcx: tcx, method_map: method_map, unsafe_context: SafeContext, }; visit::walk_crate(&mut visitor, crate, ()); }
check_crate
identifier_name
effect.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
ast::ExprAssign(base, _) | ast::ExprAssignOp(_, _, base, _) => { self.check_str_index(base); } ast::ExprAddrOf(ast::MutMutable, base) => { self.check_str_index(base); } ast::ExprInlineAsm(*) => { self.require_un...
{ let base_type = ty::node_id_to_type(self.tcx, base.id); debug2!("effect: unary case, base type is {}", ppaux::ty_to_str(self.tcx, base_type)); match ty::get(base_type).sty { ty::ty_ptr(_) => { self.requ...
conditional_block
mod.rs
pub mod elf_parser; use cpuio::Port; macro_rules! raw_ptr { (u8 $ptr:expr ; $offset:expr) => ( *(($ptr as *const u8).offset($offset / 1)) ); (u16 $ptr:expr ; $offset:expr) => ( *(($ptr as *const u16).offset($offset / 2)) ); (u32 $ptr:expr ; $offset:expr) => ( *(($ptr as *co...
}; } macro_rules! sizeof { ($t:ty) => {{ ::core::mem::size_of::<$t>() }}; }
}
random_line_split
fetch_command.rs
extern crate zip; use std::fs::{create_dir, create_dir_all, File}; use std::io::{Cursor, Read, Write}; use std::path::{Path, PathBuf}; use curl::http; use rustc_serialize::json::Json; use zip::read::ZipArchive; use version; use commands::command::Command; pub struct FetchCommand<'a> { slice_root_directory: &'a Pat...
(uri: &str) -> Vec<u8> { let mut handle = http::handle(); let request = handle.get(uri).header("user-agent", "Mozilla/4.0 (compatible)"); let response = request.exec().unwrap(); response.move_body() } fn determine_latest_version() -> String { let body = FetchCommand::exe...
execute_request_to_uri
identifier_name
fetch_command.rs
extern crate zip; use std::fs::{create_dir, create_dir_all, File}; use std::io::{Cursor, Read, Write}; use std::path::{Path, PathBuf}; use curl::http; use rustc_serialize::json::Json; use zip::read::ZipArchive; use version; use commands::command::Command; pub struct FetchCommand<'a> { slice_root_directory: &'a Pat...
fn write_bytes_to_temporary_file(bytes: &[u8], file_path: &PathBuf) { let _ = create_dir(file_path.parent().unwrap()); let mut file = File::create(file_path).unwrap(); let _ = file.write(bytes); } } impl<'a> Command for FetchCommand<'a> { fn run(&mut self) { let bytes = Fe...
{ for i in 0..zip_archive.len() { let mut path = path.clone(); let mut file = zip_archive.by_index(i).unwrap(); { let file_name = file.name(); path.push(file_name); } if file.size() != 0 { let _ = create_...
identifier_body
fetch_command.rs
extern crate zip; use std::fs::{create_dir, create_dir_all, File}; use std::io::{Cursor, Read, Write}; use std::path::{Path, PathBuf}; use curl::http; use rustc_serialize::json::Json; use zip::read::ZipArchive; use version; use commands::command::Command; pub struct FetchCommand<'a> { slice_root_directory: &'a Pat...
let response = request.exec().unwrap(); response.move_body() } fn determine_latest_version() -> String { let body = FetchCommand::execute_request_to_uri("https://api.github.\ com/repos/slicebuild/slices/branches"); let bod...
fn execute_request_to_uri(uri: &str) -> Vec<u8> { let mut handle = http::handle(); let request = handle.get(uri).header("user-agent", "Mozilla/4.0 (compatible)");
random_line_split
basic-types.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 ...
() {()}
_zzz
identifier_name
basic-types.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 ...
{()}
identifier_body
basic-types.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 ...
// about UTF-32 character encoding and will print a rust char as only // its numerical value. // compile-flags:-Z extra-debug-info // debugger:break _zzz // debugger:run // debugger:finish // debugger:print b // check:$1 = false // debugger:print i // check:$2 = -1 // debugger:print c // check:$3 = 97 // debugger:prin...
// as its numerical value along with its associated ASCII char, there // doesn't seem to be any way around this. Also, gdb doesn't know
random_line_split
dst-index.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!(&S[0], "hello"); &T[0]; // let x = &x as &Debug; }
identifier_body
dst-index.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 ...
; impl Index<usize> for S { type Output = str; fn index<'a>(&'a self, _: usize) -> &'a str { "hello" } } struct T; impl Index<usize> for T { type Output = Debug +'static; fn index<'a>(&'a self, idx: usize) -> &'a (Debug +'static) { static X: usize = 42; &X as &(Debug +'s...
S
identifier_name
dst-index.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 ...
&T[0]; // let x = &x as &Debug; }
} fn main() { assert_eq!(&S[0], "hello");
random_line_split
mod.rs
move_data::MoveData<'tcx>) { let mut glcx = GatherLoanCtxt { bccx: bccx, all_loans: Vec::new(), item_ub: region::CodeExtent::from_node_id(body.id), move_data: MoveData::new(), move_error_collector: move_error::MoveErrorCollector::new(), }; let param_env = ty:...
(&mut self, assignment_id: ast::NodeId, assignment_span: Span, assignee_cmt: mc::cmt<'tcx>, mode: euv::MutateMode) { debug!("mutate(assignment_id={}, assignee_cmt={})", assignment_id, assignee_cmt.repr(self.tcx())); match opt_lo...
mutate
identifier_name
mod.rs
move_data::MoveData<'tcx>) { let mut glcx = GatherLoanCtxt { bccx: bccx, all_loans: Vec::new(), item_ub: region::CodeExtent::from_node_id(body.id), move_data: MoveData::new(), move_error_collector: move_error::MoveErrorCollector::new(), }; let param_env = ty:...
(Some(mc::AliasableStatic(safety)), ty::ImmBorrow) => { // Borrow of an immutable static item: match safety { mc::InteriorUnsafe => { // If the static item contains an Unsafe<T>, it has interior // mutability. In such cases, anoth...
{ /* Uniquely accessible path -- OK for `&` and `&mut` */ Ok(()) }
conditional_block
mod.rs
move_data::MoveData<'tcx>) { let mut glcx = GatherLoanCtxt { bccx: bccx, all_loans: Vec::new(), item_ub: region::CodeExtent::from_node_id(body.id), move_data: MoveData::new(), move_error_collector: move_error::MoveErrorCollector::new(), }; let param_env = ty...
} gather_moves::gather_move_from_pat( self.bccx, &self.move_data, &self.move_error_collector, consume_pat, cmt); } fn borrow(&mut self, borrow_id: ast::NodeId, borrow_span: Span, cmt: mc::cmt<'tcx>, loan_region: ty...
euv::Move(_) => { }
random_line_split
mod.rs
fn matched_pat(&mut self, matched_pat: &ast::Pat, cmt: mc::cmt<'tcx>, mode: euv::MatchMode) { debug!("matched_pat(matched_pat={}, cmt={}, mode={:?})", matched_pat.repr(self.tcx()), cmt.repr(self.tcx()), m...
{ self.move_error_collector.report_potential_errors(self.bccx); }
identifier_body
mips.rs
//! Run-time feature detection for MIPS on Linux. use crate::detect::{Feature, cache, bit}; use super::auxvec; /// Performs run-time feature detection. #[inline] pub fn check_for(x: Feature) -> bool { cache::test(x as u32, detect_features) } /// Try to read the features from the auxiliary vector, and if that fai...
() -> cache::Initializer { let mut value = cache::Initializer::default(); let enable_feature = |value: &mut cache::Initializer, f, enable| { if enable { value.set(f as u32); } }; // The values are part of the platform-specific [asm/hwcap.h][hwcap] // // [hwcap]: http...
detect_features
identifier_name
mips.rs
//! Run-time feature detection for MIPS on Linux. use crate::detect::{Feature, cache, bit}; use super::auxvec; /// Performs run-time feature detection. #[inline] pub fn check_for(x: Feature) -> bool { cache::test(x as u32, detect_features) } /// Try to read the features from the auxiliary vector, and if that fai...
}; // The values are part of the platform-specific [asm/hwcap.h][hwcap] // // [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/hwcap.h if let Ok(auxv) = auxvec::auxv() { enable_feature(&mut value, Feature::msa, bit::test(auxv.hwcap, 1)); return val...
{ value.set(f as u32); }
conditional_block
mips.rs
//! Run-time feature detection for MIPS on Linux. use crate::detect::{Feature, cache, bit}; use super::auxvec; /// Performs run-time feature detection. #[inline] pub fn check_for(x: Feature) -> bool { cache::test(x as u32, detect_features) } /// Try to read the features from the auxiliary vector, and if that fai...
{ let mut value = cache::Initializer::default(); let enable_feature = |value: &mut cache::Initializer, f, enable| { if enable { value.set(f as u32); } }; // The values are part of the platform-specific [asm/hwcap.h][hwcap] // // [hwcap]: https://github.com/torvalds/l...
identifier_body
mips.rs
//! Run-time feature detection for MIPS on Linux. use crate::detect::{Feature, cache, bit}; use super::auxvec; /// Performs run-time feature detection. #[inline] pub fn check_for(x: Feature) -> bool { cache::test(x as u32, detect_features) } /// Try to read the features from the auxiliary vector, and if that fai...
}
// TODO: fall back via `cpuinfo`. value
random_line_split
action_bar.rs
// This file was generated by gir (17af302) from gir-files (11e0e6d) // DO NOT EDIT use Bin; use Buildable; use Container; use Widget; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct ActionBar(Object<ffi::GtkActionBar>): Widget, Container, Bin, Builda...
} impl ActionBar { #[cfg(feature = "3.12")] pub fn new() -> ActionBar { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(ffi::gtk_action_bar_new()).downcast_unchecked() } } #[cfg(feature = "3.12")] pub fn get_center_widget(&self) -> Option<Widg...
match fn { get_type => || ffi::gtk_action_bar_get_type(), }
random_line_split
action_bar.rs
// This file was generated by gir (17af302) from gir-files (11e0e6d) // DO NOT EDIT use Bin; use Buildable; use Container; use Widget; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct ActionBar(Object<ffi::GtkActionBar>): Widget, Container, Bin, Builda...
#[cfg(feature = "3.12")] pub fn pack_start<T: IsA<Widget>>(&self, child: &T) { unsafe { ffi::gtk_action_bar_pack_start(self.to_glib_none().0, child.to_glib_none().0); } } #[cfg(feature = "3.12")] pub fn set_center_widget<T: IsA<Widget>>(&self, center_widget: Option<&T>...
{ unsafe { ffi::gtk_action_bar_pack_end(self.to_glib_none().0, child.to_glib_none().0); } }
identifier_body
action_bar.rs
// This file was generated by gir (17af302) from gir-files (11e0e6d) // DO NOT EDIT use Bin; use Buildable; use Container; use Widget; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct ActionBar(Object<ffi::GtkActionBar>): Widget, Container, Bin, Builda...
(&self) -> Option<Widget> { unsafe { from_glib_none(ffi::gtk_action_bar_get_center_widget(self.to_glib_none().0)) } } #[cfg(feature = "3.12")] pub fn pack_end<T: IsA<Widget>>(&self, child: &T) { unsafe { ffi::gtk_action_bar_pack_end(self.to_glib_none().0, chi...
get_center_widget
identifier_name
filecontainer.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
{ if direction == Direction::ToServer { (&mut self.files_ts, self.flags_ts) } else { (&mut self.files_tc, self.flags_tc) } } } pub struct File; #[repr(C)] #[derive(Debug)] pub struct FileContainer { head: * mut c_void, tail: * mut c_void, } impl Drop for...
pub fn get(&mut self, direction: Direction) -> (&mut FileContainer, u16)
random_line_split
filecontainer.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
{ head: * mut c_void, tail: * mut c_void, } impl Drop for FileContainer { fn drop(&mut self) { self.free(); } } impl Default for FileContainer { fn default() -> Self { Self { head: ptr::null_mut(), tail: ptr::null_mut(), }} } impl FileContainer { pub fn default() ...
FileContainer
identifier_name
lib.rs
/*! **[ringbuffer operations on multiple values at once] (trait.SliceRing.html) with an [efficient implementation] (#performance)** useful for moving a window with variable step through a possibly infinite stream of values [while avoiding unnecessary memory allocations] (#memory) handy when computing the [short-time...
else { self.buf.capacity() } } #[inline] pub fn capacity(&self) -> usize { self.cap() - 1 } #[inline] pub fn is_continuous(&self) -> bool { self.first_readable <= self.next_writable } /// returns the number of elements in the `SliceRingImpl` #[...
{ // For zero sized types, we are always at maximum capacity MAXIMUM_ZST_CAPACITY }
conditional_block
lib.rs
/*! **[ringbuffer operations on multiple values at once] (trait.SliceRing.html) with an [efficient implementation] (#performance)** useful for moving a window with variable step through a possibly infinite stream of values [while avoiding unnecessary memory allocations] (#memory) handy when computing the [short-time...
/// returns the number of elements in the `SliceRingImpl` #[inline] pub fn len(&self) -> usize { count(self.first_readable, self.next_writable, self.cap()) } /// returns the index into the underlying buffer /// for a given logical element /// index + addend #[inline] pub f...
{ self.first_readable <= self.next_writable }
identifier_body
lib.rs
/*! **[ringbuffer operations on multiple values at once] (trait.SliceRing.html) with an [efficient implementation] (#performance)** useful for moving a window with variable step through a possibly infinite stream of values [while avoiding unnecessary memory allocations] (#memory) handy when computing the [short-time...
let copy_dst = old_cap; // everything before next_writable let copy_len = next_writable; self.copy_nonoverlapping(copy_src, copy_dst, copy_len); self.next_writable += old_cap; debug_assert!(self.next_writable > self.first_readable); deb...
// TODO test this if self.next_writable < old_cap - self.first_readable { let next_writable = self.next_writable; let copy_src = 0; // after the previous
random_line_split
lib.rs
/*! **[ringbuffer operations on multiple values at once] (trait.SliceRing.html) with an [efficient implementation] (#performance)** useful for moving a window with variable step through a possibly infinite stream of values [while avoiding unnecessary memory allocations] (#memory) handy when computing the [short-time...
(&self) -> usize { self.cap() - 1 } #[inline] pub fn is_continuous(&self) -> bool { self.first_readable <= self.next_writable } /// returns the number of elements in the `SliceRingImpl` #[inline] pub fn len(&self) -> usize { count(self.first_readable, self.next_writ...
capacity
identifier_name
task-comm-16.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 ...
// run-pass #![allow(unused_mut)] #![allow(unused_parens)] #![allow(non_camel_case_types)] use std::sync::mpsc::channel; use std::cmp; // Tests of ports and channels on various types fn test_rec() { struct R {val0: isize, val1: u8, val2: char} let (tx, rx) = channel(); let r0: R = R {val0: 0, val1: 1, va...
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
task-comm-16.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let (tx, rx) = channel(); let s0 = "test".to_string(); tx.send(s0).unwrap(); let s1 = rx.recv().unwrap(); assert_eq!(s1.as_bytes()[0], 't' as u8); assert_eq!(s1.as_bytes()[1], 'e' as u8); assert_eq!(s1.as_bytes()[2],'s' as u8); assert_eq!(s1.as_bytes()[3], 't' as u8); } #[derive(De...
test_str
identifier_name
task-comm-16.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 test_str() { let (tx, rx) = channel(); let s0 = "test".to_string(); tx.send(s0).unwrap(); let s1 = rx.recv().unwrap(); assert_eq!(s1.as_bytes()[0], 't' as u8); assert_eq!(s1.as_bytes()[1], 'e' as u8); assert_eq!(s1.as_bytes()[2],'s' as u8); assert_eq!(s1.as_bytes()[3], 't' as u8); }...
{ let (tx, rx) = channel(); let v0: Vec<isize> = vec![0, 1, 2]; tx.send(v0).unwrap(); let v1 = rx.recv().unwrap(); assert_eq!(v1[0], 0); assert_eq!(v1[1], 1); assert_eq!(v1[2], 2); }
identifier_body
reader.rs
macro_rules! impl_fastx_reader { ($multiline_fastq:expr, $DefaultPositionStore:ty, ($($mod_path:expr),*)) => { impl_reader!( Reader, crate::fastx::RefRecord<S>, crate::fastx::OwnedRecord, crate::fastx::RecordSet<S>, crate::fastx::Error, crate::core::QualRecordPosition, $DefaultPositionStore, true, $mul...
fn _new(reader: R, capacity: usize, policy: P) -> Self { Reader { inner: crate::core::CoreReader::new(reader, capacity, policy), fasta: None, } } #[inline] fn _from_buf_reader(rdr: crate::core::BufReader<R, P>, byte_offset: usize, line_idx: u64) -> Self { ...
R: std::io::Read, P: crate::policy::BufPolicy, S: crate::core::QualRecordPosition, { #[inline]
random_line_split
lib.rs
// Copyright (C) 2014 The 6502-rs Developers // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of ...
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR...
random_line_split
project.rs
// Evelyn: Your personal assistant, project manager and calendar // Copyright (C) 2017 Gregory Jensen // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or //...
( client: &Client, project_id: &String, user_id: &String, user_groups: Vec<model::user_group::UserGroupsExternalModel>, ) -> Result<project_model::ProjectModel, EvelynDatabaseError> { let collection = client.db("evelyn").collection("agile_project"); let mut filter = build_project_lookup_filter(...
lookup
identifier_name
project.rs
// Evelyn: Your personal assistant, project manager and calendar // Copyright (C) 2017 Gregory Jensen // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or //...
} } pub fn lookup_contributing_to( client: &Client, user_id: &String, user_groups: Vec<model::user_group::UserGroupsExternalModel>, ) -> Result<Vec<project_model::ProjectPreviewModel>, EvelynDatabaseError> { let collection = client.db("evelyn").collection("agile_project"); let filter = build_...
{ let collection = client.db("evelyn").collection("agile_project"); let ref project_id = user_group_contributor_model.project_id; let filter = doc!("projectId" => project_id); let mut update_query = Document::new(); let bson_user_group_contributor_model = bson::to_bson(&user_group_contributor_mode...
identifier_body
project.rs
// Evelyn: Your personal assistant, project manager and calendar // Copyright (C) 2017 Gregory Jensen // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or //...
} pub fn lookup_contributing_to( client: &Client, user_id: &String, user_groups: Vec<model::user_group::UserGroupsExternalModel>, ) -> Result<Vec<project_model::ProjectPreviewModel>, EvelynDatabaseError> { let collection = client.db("evelyn").collection("agile_project"); let filter = build_projec...
{ Some(EvelynDatabaseError::SerialisationFailed(EvelynBaseError::NothingElse)) }
conditional_block
project.rs
// Evelyn: Your personal assistant, project manager and calendar // Copyright (C) 2017 Gregory Jensen // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or //...
let ref project_id = user_contributor_model.project_id; let filter = doc!("projectId" => project_id); let mut update_query = Document::new(); let bson_user_contributor_model = bson::to_bson(&user_contributor_model.user_contributor).unwrap(); if let bson::Bson::Document(document) = bson_user_contri...
) -> Option<EvelynDatabaseError> { let collection = client.db("evelyn").collection("agile_project");
random_line_split
hofstadter_q.rs
// http://rosettacode.org/wiki/Hofstadter_Q_sequence // An iterable version. // Define a struct which stores the state for the iterator. struct
{ next: usize, memoize_vec: Vec<usize> } impl HofstadterQ { // Define a constructor for the struct. fn new() -> HofstadterQ { HofstadterQ { next: 1, memoize_vec: vec![1] } } } // Implement the hofstadter q iteration sequence. impl Iterator for HofstadterQ { type Item = usize; // Thi...
HofstadterQ
identifier_name
hofstadter_q.rs
// http://rosettacode.org/wiki/Hofstadter_Q_sequence // An iterable version. // Define a struct which stores the state for the iterator. struct HofstadterQ { next: usize, memoize_vec: Vec<usize> } impl HofstadterQ { // Define a constructor for the struct. fn new() -> HofstadterQ { HofstadterQ { ...
for _ in 3..upto { it.next(); } assert_eq!(expected, it.next().unwrap()); }
random_line_split
data_loader.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/. */ extern crate hyper; use ipc_channel::ipc; use net_traits::LoadConsumer::Channel; use net_traits::LoadData; use ne...
#[test] fn base64_ct() { assert_parse("data:application/octet-stream;base64,C62+7w==", Some(ContentType(Mime(TopLevel::Application, SubLevel::Ext("octet-stream".to_string()), vec!()))), None, Some(vec!(0x0B, 0xAD, 0xBE, 0xEF))); } #[test] fn base64_charset() { assert_parse("data:text/...
{ assert_parse( "data:;base64,C62+7w==", Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, vec!((Attr::Charset, Value::Ext("us-ascii".to_owned())))))), Some("US-ASCII".to_owned()), Some(vec!(0x0B, 0xAD, 0xBE, 0xEF))); }
identifier_body
data_loader.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/. */ extern crate hyper; use ipc_channel::ipc; use net_traits::LoadConsumer::Channel; use net_traits::LoadData; use ne...
() { assert_parse( "data:;base64,C62+7w==", Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, vec!((Attr::Charset, Value::Ext("us-ascii".to_owned())))))), Some("US-ASCII".to_owned()), Some(vec!(0x0B, 0xAD, 0xBE, 0xEF))); } #[t...
base64
identifier_name
data_loader.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/. */ extern crate hyper; use ipc_channel::ipc; use net_traits::LoadConsumer::Channel; use net_traits::LoadData; use ne...
Some(dat) => { assert_eq!(progress, Payload(dat)); assert_eq!(response.progress_port.recv().unwrap(), Done(Ok(()))); } } } #[test] fn empty_invalid() { assert_parse("data:", None, None, None); } #[test] fn plain() { assert_parse( "data:,hello%20world", ...
{ assert_eq!(progress, Done(Err("invalid data uri".to_string()))); }
conditional_block
data_loader.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/. */ extern crate hyper; use ipc_channel::ipc; use net_traits::LoadConsumer::Channel; use net_traits::LoadData; use ne...
let classifier = Arc::new(MIMEClassifier::new()); load(LoadData::new(Url::parse(url).unwrap(), None), Channel(start_chan), classifier, CancellationListener::new(None)); let response = start_port.recv().unwrap(); assert_eq!(&response.metadata.content_type, &content_type); assert_eq...
let (start_chan, start_port) = ipc::channel().unwrap();
random_line_split
issue-23649-1.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::mem; pub struct X([u8]); fn _f(x: &X) -> usize { match *x { X(ref x) => { x....
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
issue-23649-1.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 ...
() { let b: &[u8] = &[11; 42]; let v: &X = unsafe { mem::transmute(b) }; assert_eq!(_f(v), 42); }
main
identifier_name
issue-23649-1.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 ...
} } fn main() { let b: &[u8] = &[11; 42]; let v: &X = unsafe { mem::transmute(b) }; assert_eq!(_f(v), 42); }
{ x.len() }
conditional_block
issue-23649-1.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 ...
fn main() { let b: &[u8] = &[11; 42]; let v: &X = unsafe { mem::transmute(b) }; assert_eq!(_f(v), 42); }
{ match *x { X(ref x) => { x.len() } } }
identifier_body
disc.rs
use crate::types::*; use derive_more::From; use futures::stream::BoxStream; use std::{collections::HashMap, net::SocketAddr, task::Poll}; use tokio_stream::Stream; #[cfg(feature = "discv4")] mod v4; #[cfg(feature = "discv4")] pub use self::v4::{Discv4, Discv4Builder}; #[cfg(feature = "discv4")] pub use discv4; #[cfg...
} } }
random_line_split
disc.rs
use crate::types::*; use derive_more::From; use futures::stream::BoxStream; use std::{collections::HashMap, net::SocketAddr, task::Poll}; use tokio_stream::Stream; #[cfg(feature = "discv4")] mod v4; #[cfg(feature = "discv4")] pub use self::v4::{Discv4, Discv4Builder}; #[cfg(feature = "discv4")] pub use discv4; #[cfg...
}
{ if let Some((&addr, &id)) = self.0.iter().next() { Poll::Ready(Some(Ok(NodeRecord { id, addr }))) } else { Poll::Ready(None) } }
identifier_body
disc.rs
use crate::types::*; use derive_more::From; use futures::stream::BoxStream; use std::{collections::HashMap, net::SocketAddr, task::Poll}; use tokio_stream::Stream; #[cfg(feature = "discv4")] mod v4; #[cfg(feature = "discv4")] pub use self::v4::{Discv4, Discv4Builder}; #[cfg(feature = "discv4")] pub use discv4; #[cfg...
(pub HashMap<SocketAddr, PeerId>); impl Stream for Bootnodes { type Item = anyhow::Result<NodeRecord>; fn poll_next( self: std::pin::Pin<&mut Self>, _: &mut std::task::Context<'_>, ) -> std::task::Poll<Option<Self::Item>> { if let Some((&addr, &id)) = self.0.iter().next() { ...
Bootnodes
identifier_name
disc.rs
use crate::types::*; use derive_more::From; use futures::stream::BoxStream; use std::{collections::HashMap, net::SocketAddr, task::Poll}; use tokio_stream::Stream; #[cfg(feature = "discv4")] mod v4; #[cfg(feature = "discv4")] pub use self::v4::{Discv4, Discv4Builder}; #[cfg(feature = "discv4")] pub use discv4; #[cfg...
else { Poll::Ready(None) } } }
{ Poll::Ready(Some(Ok(NodeRecord { id, addr }))) }
conditional_block
msgsend-ring-mutex-arcs.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 recv(p: &pipe) -> uint { unsafe { p.access_cond(|state, cond| { while state.is_empty() { cond.wait(); } state.pop() }) } } fn init() -> (pipe,pipe) { let m = arc::MutexArc::new(~[]); ((&m).clone(), m) } fn thread_ring(i: uint, co...
{ unsafe { p.access_cond(|state, cond| { state.push(msg); cond.signal(); }) } }
identifier_body
msgsend-ring-mutex-arcs.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(i: uint, count: uint, num_chan: pipe, num_port: pipe) { let mut num_chan = Some(num_chan); let mut num_port = Some(num_port); // Send/Receive lots of messages. for j in range(0u, count) { //error!("task %?, iter %?", i, j); let num_chan2 = num_chan.take_unwrap(); let num_port2 =...
thread_ring
identifier_name
msgsend-ring-mutex-arcs.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
else { args.clone() }; let num_tasks = from_str::<uint>(args[1]).unwrap(); let msg_per_task = from_str::<uint>(args[2]).unwrap(); let (mut num_chan, num_port) = init(); let start = time::precise_time_s(); // create the ring let mut futures = ~[]; for i in range(1u, num_task...
{ ~[~"", ~"10", ~"100"] }
conditional_block
msgsend-ring-mutex-arcs.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 ...
num_chan = Some(num_chan2); let _n = recv(&num_port2); //log(error, _n); num_port = Some(num_port2); }; } fn main() { let args = os::args(); let args = if os::getenv("RUST_BENCH").is_some() { ~[~"", ~"100", ~"10000"] } else if args.len() <= 1u { ~[~"", ~"...
random_line_split
lib.rs
// Copyright 2020 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...
// It is often more clear to show that nothing is being moved. #![allow(clippy::match_ref_pats)] // Subjective style. #![allow( clippy::len_without_is_empty, clippy::redundant_field_names, clippy::too_many_arguments )] // Default isn't as big a deal as people seem to think it is. #![allow(clippy::new_without_defa...
// TODO: Falsely triggers for async/await: // see https://github.com/rust-lang/rust-clippy/issues/5360 // clippy::used_underscore_binding )]
random_line_split
flag.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
/// True if status indicates the child continued after a stop. pub fn wifcontinued(status: usize) -> bool { status == 0xffff } /// True if STATUS indicates termination by a signal. pub fn wifsignaled(status: usize) -> bool { ((status & 0x7f) + 1) as i8 >= 2 } /// If wifsignaled(status), the terminating sign...
{ (status >> 8) & 0xff }
identifier_body
flag.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(status: usize) -> bool { status == 0xffff } /// True if STATUS indicates termination by a signal. pub fn wifsignaled(status: usize) -> bool { ((status & 0x7f) + 1) as i8 >= 2 } /// If wifsignaled(status), the terminating signal. pub fn wtermsig(status: usize) -> usize { status & 0x7f } /// True if statu...
wifcontinued
identifier_name
flag.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub const O_TRUNC: usize = 0x0400_0000; pub const O_EXCL: usize = 0x0800_0000; pub const O_DIRECTORY: usize = 0x1000_0000; pub const O_STAT: usize = 0x2000_0000; pub const O_SYMLINK: usize = 0x4000_0000; pub const O_NOFOLLOW: usize = 0x8000_0000; pub const O_ACCMODE: usize = O_RDONLY | O_WRONL...
pub const O_FSYNC: usize = 0x0080_0000; pub const O_CLOEXEC: usize = 0x0100_0000; pub const O_CREAT: usize = 0x0200_0000;
random_line_split
handlers.rs
extern crate libc; extern crate rustc_serialize; use std::rc::Rc; use core::workspaces::Workspaces; use window_manager::WindowManager; use window_system::WindowSystem; use window_system::Window; use config::{ GeneralConfig, Config }; pub type KeyHandler = Box<Fn(WindowManager, Rc<WindowSystem>, &GeneralConfig) -> Win...
; spawn(move || { debug!("spawning terminal"); let command = if arguments.is_empty() { Command::new(&terminal).spawn() } else { Command::new(&terminal).args(&arguments[..]).spawn() }; if let Err(_) = command { ...
{ args.split(' ').map(|x| x.to_owned()).collect() }
conditional_block
handlers.rs
extern crate libc; extern crate rustc_serialize; use std::rc::Rc; use core::workspaces::Workspaces; use window_manager::WindowManager; use window_system::WindowSystem; use window_system::Window; use config::{ GeneralConfig, Config }; pub type KeyHandler = Box<Fn(WindowManager, Rc<WindowSystem>, &GeneralConfig) -> Win...
(index: u32, workspace: Workspaces, window: Window) -> Workspaces { workspace.shift_window(index, window) } }
shift
identifier_name
handlers.rs
extern crate libc; extern crate rustc_serialize; use std::rc::Rc; use core::workspaces::Workspaces; use window_manager::WindowManager; use window_system::WindowSystem; use window_system::Window; use config::{ GeneralConfig, Config }; pub type KeyHandler = Box<Fn(WindowManager, Rc<WindowSystem>, &GeneralConfig) -> Win...
}; spawn(move || { debug!("spawning terminal"); let command = if arguments.is_empty() { Command::new(&terminal).spawn() } else { Command::new(&terminal).args(&arguments[..]).spawn() }; if let Err(_) = command {...
random_line_split
handlers.rs
extern crate libc; extern crate rustc_serialize; use std::rc::Rc; use core::workspaces::Workspaces; use window_manager::WindowManager; use window_system::WindowSystem; use window_system::Window; use config::{ GeneralConfig, Config }; pub type KeyHandler = Box<Fn(WindowManager, Rc<WindowSystem>, &GeneralConfig) -> Win...
CString::new(resume.as_bytes()).unwrap().as_ptr(), CString::new(windows.as_bytes()).unwrap().as_ptr(), null() ]; execvp(filename_c.as_ptr(), slice.as_mut_ptr()); } window_manager.clone() } /// Stop the window manager ...
{ // Get absolute path to binary let filename = env::current_dir().unwrap().join(&env::current_exe().unwrap()); // Collect all managed windows let window_ids : String = json::encode(&window_manager.workspaces.all_windows_with_workspaces()).unwrap(); // Create arguments l...
identifier_body
subs.rs
//! Module for `Finding a Motif in DNA` use RosalindResult; use RosalindError::MotifStringsLengthError; /// This function finds locations of substring `t` in string `s` (finds a motif in DNA) /// /// ``` /// use rosalind::RosalindError::MotifStringsLengthError; /// use rosalind::subs::*; /// /// let s = "GATATATGCAT...
#[test] fn it_should_return_error_when_substring_t_is_longer_than_s() { let s = "ATAT"; let t = "GATATATGCATATACTT"; assert_eq!(motif_lookup(s, t).unwrap_err(), MotifStringsLengthError); } }
{ let s = "GATATATGCATATACTT"; let t = "ATAT"; assert_eq!(motif_lookup(s, t).unwrap(), vec![2, 4, 10]); }
identifier_body
subs.rs
//! Module for `Finding a Motif in DNA` use RosalindResult; use RosalindError::MotifStringsLengthError; /// This function finds locations of substring `t` in string `s` (finds a motif in DNA) /// /// ``` /// use rosalind::RosalindError::MotifStringsLengthError; /// use rosalind::subs::*; /// /// let s = "GATATATGCAT...
} Ok(motif) } #[cfg(test)] mod tests { use super::motif_lookup; use super::super::RosalindError::MotifStringsLengthError; #[test] fn it_should_return_all_locations_of_substring_t_in_s() { let s = "GATATATGCATATACTT"; let t = "ATAT"; assert_eq!(motif_lookup(s, t).unwrap(), vec![2, 4, 10]); }...
{ motif.push(i + 1); }
conditional_block
subs.rs
//! Module for `Finding a Motif in DNA` use RosalindResult; use RosalindError::MotifStringsLengthError; /// This function finds locations of substring `t` in string `s` (finds a motif in DNA) /// /// ``` /// use rosalind::RosalindError::MotifStringsLengthError; /// use rosalind::subs::*; /// /// let s = "GATATATGCAT...
(s: &str, t: &str) -> RosalindResult<Vec<usize>> { let (s_len, t_len) = (s.len(), t.len()); if s_len < t_len { return Err(MotifStringsLengthError); } let mut motif: Vec<usize> = Vec::new(); for i in 0..(s_len - t_len + 1) { if s[i..].starts_with(t) { motif.push(i + 1); } } Ok(motif) } #[cfg(test)] mod ...
motif_lookup
identifier_name
subs.rs
//! Module for `Finding a Motif in DNA` use RosalindResult; use RosalindError::MotifStringsLengthError; /// This function finds locations of substring `t` in string `s` (finds a motif in DNA) /// /// ``` /// use rosalind::RosalindError::MotifStringsLengthError; /// use rosalind::subs::*; /// /// let s = "GATATATGCAT...
#[test] fn it_should_return_all_locations_of_substring_t_in_s() { let s = "GATATATGCATATACTT"; let t = "ATAT"; assert_eq!(motif_lookup(s, t).unwrap(), vec![2, 4, 10]); } #[test] fn it_should_return_error_when_substring_t_is_longer_than_s() { let s = "ATAT"; let t = "GATATATGCATATACTT"; ...
random_line_split
conditional-dispatch.rs
// run-pass
#![feature(box_syntax)] trait Get { fn get(&self) -> Self; } trait MyCopy { fn copy(&self) -> Self; } impl MyCopy for u16 { fn copy(&self) -> Self { *self } } impl MyCopy for u32 { fn copy(&self) -> Self { *self } } impl MyCopy for i32 { fn copy(&self) -> Self { *self } } impl<T:Copy> MyCopy for Option<T> { fn c...
// Test that we are able to resolve conditional dispatch. Here, the // blanket impl for T:Copy coexists with an impl for Box<T>, because // Box does not impl Copy.
random_line_split
conditional-dispatch.rs
// run-pass // Test that we are able to resolve conditional dispatch. Here, the // blanket impl for T:Copy coexists with an impl for Box<T>, because // Box does not impl Copy. #![feature(box_syntax)] trait Get { fn get(&self) -> Self; } trait MyCopy { fn copy(&self) -> Self; } impl MyCopy for u16 { fn copy(&sel...
} fn get_it<T:Get>(t: &T) -> T { (*t).get() } fn main() { assert_eq!(get_it(&1_u32), 1_u32); assert_eq!(get_it(&1_u16), 1_u16); assert_eq!(get_it(&Some(1_u16)), Some(1_u16)); assert_eq!(get_it(&Box::new(1)), Box::new(1)); }
{ box get_it(&**self) }
identifier_body
conditional-dispatch.rs
// run-pass // Test that we are able to resolve conditional dispatch. Here, the // blanket impl for T:Copy coexists with an impl for Box<T>, because // Box does not impl Copy. #![feature(box_syntax)] trait Get { fn get(&self) -> Self; } trait MyCopy { fn copy(&self) -> Self; } impl MyCopy for u16 { fn
(&self) -> Self { *self } } impl MyCopy for u32 { fn copy(&self) -> Self { *self } } impl MyCopy for i32 { fn copy(&self) -> Self { *self } } impl<T:Copy> MyCopy for Option<T> { fn copy(&self) -> Self { *self } } impl<T:MyCopy> Get for T { fn get(&self) -> T { self.copy() } } impl Get for Box<i32> { fn get(&s...
copy
identifier_name
gesture_long_press.rs
// This file was generated by gir (17af302) from gir-files (11e0e6d) // DO NOT EDIT use EventController; use Gesture; use GestureSingle; #[cfg(feature = "3.14")] use Widget; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct GestureLongPress(Object<ffi::...
}
{ skip_assert_initialized!(); unsafe { Gesture::from_glib_full(ffi::gtk_gesture_long_press_new(widget.to_glib_none().0)).downcast_unchecked() } }
identifier_body
gesture_long_press.rs
// This file was generated by gir (17af302) from gir-files (11e0e6d) // DO NOT EDIT use EventController; use Gesture; use GestureSingle; #[cfg(feature = "3.14")] use Widget; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct GestureLongPress(Object<ffi::...
#[cfg(feature = "3.14")] pub fn new<T: IsA<Widget>>(widget: &T) -> GestureLongPress { skip_assert_initialized!(); unsafe { Gesture::from_glib_full(ffi::gtk_gesture_long_press_new(widget.to_glib_none().0)).downcast_unchecked() } } }
} } impl GestureLongPress {
random_line_split
gesture_long_press.rs
// This file was generated by gir (17af302) from gir-files (11e0e6d) // DO NOT EDIT use EventController; use Gesture; use GestureSingle; #[cfg(feature = "3.14")] use Widget; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct GestureLongPress(Object<ffi::...
<T: IsA<Widget>>(widget: &T) -> GestureLongPress { skip_assert_initialized!(); unsafe { Gesture::from_glib_full(ffi::gtk_gesture_long_press_new(widget.to_glib_none().0)).downcast_unchecked() } } }
new
identifier_name
htmldatalistelement.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::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataLi...
} impl<'a> HTMLDataListElementMethods for JSRef<'a, HTMLDataListElement> { fn Options(self) -> Temporary<HTMLCollection> { #[jstraceable] struct HTMLDataListOptionsFilter; impl CollectionFilter for HTMLDataListOptionsFilter { fn filter(&self, elem: JSRef<Element>, _root: JSRef<...
{ let element = HTMLDataListElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLDataListElementBinding::Wrap) }
identifier_body
htmldatalistelement.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::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataLi...
; impl CollectionFilter for HTMLDataListOptionsFilter { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool { elem.is_htmloptionelement() } } let node: JSRef<Node> = NodeCast::from_ref(self); let filter = box HTMLDataListOptionsFilte...
HTMLDataListOptionsFilter
identifier_name
htmldatalistelement.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::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataLi...
} impl HTMLDataListElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLDataListElement { HTMLDataListElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLDataListElement, localName, prefix, document) } } ...
random_line_split
subst.rs
PerParamSpace::empty(), regions: NonerasedRegions(VecPerParamSpace::empty()), } } pub fn trans_empty() -> Substs<'tcx> { Substs { types: VecPerParamSpace::empty(), regions: ErasedRegions } } pub fn is_noop(&self) -> bool { let regions...
pub fn replace(&mut self, space: ParamSpace, elems: Vec<T>) { // FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n). self.truncate(space, 0); for t in elems { self.push(space, t); } } pub fn get_self<'a>(&'a self) -> Option<&'a T> { let v =...
{ // FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n). while self.len(space) > len { self.pop(space); } }
identifier_body
subst.rs
PerParamSpace::empty(), regions: NonerasedRegions(VecPerParamSpace::empty()), } } pub fn trans_empty() -> Substs<'tcx> { Substs { types: VecPerParamSpace::empty(), regions: ErasedRegions } } pub fn is_noop(&self) -> bool { let regions...
(t: Vec<T>, s: Vec<T>, f: Vec<T>) -> VecPerParamSpace<T> { let type_limit = t.len(); let self_limit = type_limit + s.len(); let mut content = t; content.extend(s); content.extend(f); VecPerParamSpace { type_limit: type_limit, self_limit: self_lim...
new
identifier_name
subst.rs
VecPerParamSpace::empty(), regions: NonerasedRegions(VecPerParamSpace::empty()), } } pub fn trans_empty() -> Substs<'tcx> { Substs { types: VecPerParamSpace::empty(), regions: ErasedRegions } } pub fn is_noop(&self) -> bool { let reg...
NonerasedRegions(_) => false, } } } /////////////////////////////////////////////////////////////////////////// // ParamSpace #[derive(PartialOrd, Ord, PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable, Debug)] pub enum ParamSpace { TypeSpace, // Type parameters ...
pub fn is_erased(&self) -> bool { match *self { ErasedRegions => true,
random_line_split
local_image_cache.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/. */ /*! An adapter for ImageCacheTask that does local caching to avoid extra message traffic, it also avoids waiting o...
} } let (response_chan, response_port) = channel(); self.image_cache_task.send(GetImage((*url).clone(), response_chan)); let response = response_port.recv(); match response { ImageNotReady => { // Need to reflow when the image is availabl...
let (chan, port) = channel(); chan.send(ImageFailed); return port; }
random_line_split
local_image_cache.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/. */ /*! An adapter for ImageCacheTask that does local caching to avoid extra message traffic, it also avoids waiting o...
{ image_cache_task: ImageCacheTask, round_number: uint, on_image_available: Option<Box<ImageResponder+Send>>, state_map: HashMap<Url, ImageState> } impl LocalImageCache { pub fn new(image_cache_task: ImageCacheTask) -> LocalImageCache { LocalImageCache { image_cache_task: image...
LocalImageCache
identifier_name
slice-2.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 = Foo; x[]; //~ ERROR cannot take a slice of a value with type `Foo` x[Foo..]; //~ ERROR cannot take a slice of a value with type `Foo` x[..Foo]; //~ ERROR cannot take a slice of a value with type `Foo` x[Foo..Foo]; //~ ERROR cannot take a slice of a value with type `Foo` x[mut]; //~ ERR...
identifier_body
slice-2.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
// option. This file may not be copied, modified, or distributed // except according to those terms. // Test that slicing syntax gives errors if we have not implemented the trait. struct Foo; fn main() { let x = Foo; x[]; //~ ERROR cannot take a slice of a value with type `Foo` x[Foo..]; //~ ERROR cannot...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
slice-2.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 = Foo; x[]; //~ ERROR cannot take a slice of a value with type `Foo` x[Foo..]; //~ ERROR cannot take a slice of a value with type `Foo` x[..Foo]; //~ ERROR cannot take a slice of a value with type `Foo` x[Foo..Foo]; //~ ERROR cannot take a slice of a value with type `Foo` x[mut]; //~ ...
main
identifier_name
macros.rs
/// Define a trait as usual, and a macro that can be used to instantiate /// implementations of it. /// /// There *must* be section markers in the trait definition: /// @section type for associated types /// @section self for methods /// @section nodelegate for arbitrary tail that is not forwarded. macro_rules! trait_t...
}) => { impl<$($param)*> $name for $self_wrap where $self_type: $name { $( $( type $assoc_name = $self_type::$assoc_name; )* )* $( type $assoc_name_ext = $self_type::$assoc_name_ext; )* $( ...
// Arbitrary tail that is ignored when forwarding. $( @section nodelegate $($tail:tt)* )*
random_line_split
lib.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 ...
(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Box<base::MacResult> { let (expr, endian) = parse_tts(cx, tts); let little = match endian { None => false, Some(Ident{ident, span}) => match token::get_ident(ident).get() { "little" => true, ...
expand_syntax_ext
identifier_name
lib.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
use syntax::parse::token::InternedString; use rustc::plugin::Registry; use std::gc::Gc; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { reg.register_macro("fourcc", expand_syntax_ext); } pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Box...
use syntax::ext::base; use syntax::ext::base::{ExtCtxt, MacExpr}; use syntax::ext::build::AstBuilder; use syntax::parse::token;
random_line_split
lib.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 ...
// FIXME (10872): This is required to prevent an LLVM assert on Windows #[test] fn dummy_test() { }
{ let meta = cx.meta_name_value(sp, InternedString::new("target_endian"), ast::LitStr(InternedString::new("little"), ast::CookedStr)); contains(cx.cfg().as_slice(), meta) }
identifier_body
lib.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 ...
}, _ => { cx.span_err(expr.span, "non-literal in fourcc!"); return base::DummyResult::expr(sp) } }; let mut val = 0u32; for codepoint in s.get().chars().take(4) { let byte = if codepoint as u32 > 0xFF { cx.span_err(expr.span, "fourcc! lit...
{ cx.span_err(expr.span, "unsupported literal in fourcc!"); return base::DummyResult::expr(sp) }
conditional_block