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
maildir.rs
use std::time::Duration; use chan::Sender; use block::{Block, ConfigBlock}; use config::Config; use de::deserialize_duration; use errors::*; use widgets::text::TextWidget; use widget::{I3BarWidget, State}; use input::I3BarEvent; use scheduler::Task; use maildir::Maildir as ExtMaildir; use uuid::Uuid; pub struct Mail...
fn click(&mut self, _: &I3BarEvent) -> Result<()> { Ok(()) } fn id(&self) -> &str { &self.id } }
{ vec![&self.text] }
identifier_body
maildir.rs
use std::time::Duration; use chan::Sender; use block::{Block, ConfigBlock}; use config::Config; use de::deserialize_duration; use errors::*; use widgets::text::TextWidget; use widget::{I3BarWidget, State}; use input::I3BarEvent; use scheduler::Task; use maildir::Maildir as ExtMaildir; use uuid::Uuid; pub struct Mail...
fn update(&mut self) -> Result<Option<Duration>> { let mut newmails = 0; for inbox in &self.inboxes { let isl: &str = &inbox[..]; let maildir = ExtMaildir::from(isl); newmails += maildir.count_new(); } let mut state = { State::Idle }; if ne...
}) } } impl Block for Maildir {
random_line_split
maildir.rs
use std::time::Duration; use chan::Sender; use block::{Block, ConfigBlock}; use config::Config; use de::deserialize_duration; use errors::*; use widgets::text::TextWidget; use widget::{I3BarWidget, State}; use input::I3BarEvent; use scheduler::Task; use maildir::Maildir as ExtMaildir; use uuid::Uuid; pub struct Mail...
(&self) -> Vec<&I3BarWidget> { vec![&self.text] } fn click(&mut self, _: &I3BarEvent) -> Result<()> { Ok(()) } fn id(&self) -> &str { &self.id } }
view
identifier_name
memory.rs
//! Memory logic for the context sub-system. //! //! Some parts of this code are based on the Redox OS. use alloc::arc::{Arc, Weak}; use spin::Mutex; use arch::memory::paging::{ActivePageTable, Page, PageIter, VirtualAddress}; use arch::memory::paging::entry::EntryFlags; use arch::start; #[derive(Clone, Debug)] pub ...
(self) -> SharedMemory { SharedMemory::Owned(Arc::new(Mutex::new(self))) } /// Map a new space on the virtual memory for this memory zone. fn map(&mut self, clean: bool) { // create a new active page table let mut active_table = unsafe { ActivePageTable::new() }; // get mem...
to_shared
identifier_name
memory.rs
//! Memory logic for the context sub-system. //! //! Some parts of this code are based on the Redox OS. use alloc::arc::{Arc, Weak}; use spin::Mutex; use arch::memory::paging::{ActivePageTable, Page, PageIter, VirtualAddress}; use arch::memory::paging::entry::EntryFlags; use arch::start; #[derive(Clone, Debug)] pub ...
else { panic!("Memory controller required"); } } /// Remap a memory area to another region pub fn remap(&mut self, new_flags: EntryFlags) { // create a new page table let mut active_table = unsafe { ActivePageTable::new() }; // get memory controller if ...
{ for page in self.pages() { memory_controller.map(&mut active_table, page, self.flags); } }
conditional_block
memory.rs
//! Memory logic for the context sub-system. //! //! Some parts of this code are based on the Redox OS. use alloc::arc::{Arc, Weak}; use spin::Mutex; use arch::memory::paging::{ActivePageTable, Page, PageIter, VirtualAddress}; use arch::memory::paging::entry::EntryFlags; use arch::start; #[derive(Clone, Debug)] pub ...
/// Get an iterator with the page range for this memory zone. pub fn pages(&self) -> PageIter { let start_page = Page::containing_address(self.start); let end_page = Page::containing_address((self.start as usize + self.size - 1) as VirtualAddress); Page::range_inclusive(start_page, end...
{ self.flags }
identifier_body
memory.rs
//! Memory logic for the context sub-system. //! //! Some parts of this code are based on the Redox OS. use alloc::arc::{Arc, Weak}; use spin::Mutex; use arch::memory::paging::{ActivePageTable, Page, PageIter, VirtualAddress}; use arch::memory::paging::entry::EntryFlags; use arch::start; #[derive(Clone, Debug)] pub ...
start, size, flags }; // map the memory and clean it if requested memory.map(clear); memory } /// Get the start address for this memory space. pub fn start_address(&self) -> VirtualAddress { self.start } /// Get the size...
impl Memory { /// Create a new Memory instance. pub fn new(start: VirtualAddress, size: usize, flags: EntryFlags, clear: bool) -> Self { let mut memory = Memory {
random_line_split
grammar.rs
#[derive(Debug)] #[derive(Clone)] #[derive(PartialEq)] pub enum AddOp { Add, Subtract, Start, } #[derive(Debug)] #[derive(Clone)] #[derive(PartialEq)] pub enum MultOp { Multiply, Divide, Modulo, Start, } #[derive(Clone)] #[derive(Debug)] #[derive(PartialEq)] pub struct AddTerm(pub AddOp, pub Expr); #[d...
CLt, // < CNeq, //!= CGeq, // >= CLeq, // <= }
pub enum Comparator { CEq, // == CGt, // >
random_line_split
grammar.rs
#[derive(Debug)] #[derive(Clone)] #[derive(PartialEq)] pub enum
{ Add, Subtract, Start, } #[derive(Debug)] #[derive(Clone)] #[derive(PartialEq)] pub enum MultOp { Multiply, Divide, Modulo, Start, } #[derive(Clone)] #[derive(Debug)] #[derive(PartialEq)] pub struct AddTerm(pub AddOp, pub Expr); #[derive(Clone)] #[derive(Debug)] #[derive(PartialEq)] pub struct MultTe...
AddOp
identifier_name
arena.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 ...
(base: uint, align: uint) -> uint { (base + (align - 1)) &!(align - 1) } // Walk down a chunk, running the destructors for any objects stored // in it. unsafe fn destroy_chunk(chunk: &Chunk) { let mut idx = 0; let buf = vec::raw::to_ptr(chunk.data); let fill = chunk.fill; while idx < fill { ...
round_up_to
identifier_name
arena.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 ...
head.fill = round_up_to(end, sys::pref_align_of::<*TypeDesc>()); //debug!("idx = %u, size = %u, align = %u, fill = %u", // start, n_bytes, align, head.fill); let buf = vec::raw::to_ptr(head.data); return (ptr::offset(buf, tydesc_start), ptr::offset(bu...
{ return self.alloc_nonpod_grow(n_bytes, align); }
conditional_block
arena.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 ...
// is necessary in order to properly do cleanup if a failure occurs // during an initializer. #[inline(always)] unsafe fn bitpack_tydesc_ptr(p: *TypeDesc, is_done: bool) -> uint { let p_bits: uint = transmute(p); p_bits | (is_done as uint) } #[inline(always)] unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDe...
// We encode whether the object a tydesc describes has been // initialized in the arena in the low bit of the tydesc pointer. This
random_line_split
arena.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 ...
// The external interface #[inline(always)] fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T { unsafe { // XXX: Borrow check let this = transmute_mut_region(self); if!rusti::needs_drop::<T>() { return this.alloc_pod(op); } ...
{ unsafe { let tydesc = sys::get_type_desc::<T>(); let (ty_ptr, ptr) = self.alloc_nonpod_inner((*tydesc).size, (*tydesc).align); let ty_ptr: *mut uint = transmute(ty_ptr); let ptr: *mut T = transmute(ptr); // Write in our tydesc along w...
identifier_body
discord.rs
use inth_oauth2::provider::Provider; use inth_oauth2::token::{Bearer, Refresh}; use inth_oauth2::Client; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Discord; #[derive(RustcDecodable)] pub struct DiscordUser { pub username: String, pub verified: bool, pub mfa_enabled: bool, pub id: String, ...
{ Client::<Discord>::new( // XXX don't commit these to git that would be very bad // String::from(""), // String::from(""), // Some(String::from("")) ) }
identifier_body
discord.rs
use inth_oauth2::provider::Provider; use inth_oauth2::token::{Bearer, Refresh}; use inth_oauth2::Client; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Discord; #[derive(RustcDecodable)] pub struct DiscordUser { pub username: String, pub verified: bool, pub mfa_enabled: bool, pub id: String, ...
() -> &'static str { "https://discordapp.com/api/oauth2/authorize" } fn token_uri() -> &'static str { "https://discordapp.com/api/oauth2/token" } } pub const DISCORD_SCOPES: &'static str = "identify email guilds"; pub fn get_client() -> Client<Discord> { Client::<Discord>::new( // XXX don't commit the...
auth_uri
identifier_name
discord.rs
use inth_oauth2::provider::Provider; use inth_oauth2::token::{Bearer, Refresh}; use inth_oauth2::Client; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Discord; #[derive(RustcDecodable)] pub struct DiscordUser { pub username: String, pub verified: bool, pub mfa_enabled: bool, pub id: String, ...
pub const DISCORD_SCOPES: &'static str = "identify email guilds"; pub fn get_client() -> Client<Discord> { Client::<Discord>::new( // XXX don't commit these to git that would be very bad // String::from(""), // String::from(""), // Some(String::from("")) ) }
}
random_line_split
addition.rs
extern crate basiccms; #[cfg(test)] mod tests { use basiccms::*; #[test] #[should_panic] fn you_cannot_add_two_sketches_together_if_they_have_different_hashers () { let mut left = Sketch::new(0.0001, 0.99); let mut right = Sketch::new(0.0001, 0.99); left.add(1); right.add(1...
#[test] fn but_you_can_add_together_two_sketches_from_a_common_base () { let mut left = Sketch::new(0.0001, 0.99); let mut right = left.clone(); left.add(1); right.add(1); let mut third = &left + &right; assert_eq!(1, left.point(1)); assert_eq!(1, righ...
let mut third = &left + &right; third.point(1); }
random_line_split
addition.rs
extern crate basiccms; #[cfg(test)] mod tests { use basiccms::*; #[test] #[should_panic] fn you_cannot_add_two_sketches_together_if_they_have_different_hashers ()
#[test] fn but_you_can_add_together_two_sketches_from_a_common_base () { let mut left = Sketch::new(0.0001, 0.99); let mut right = left.clone(); left.add(1); right.add(1); let mut third = &left + &right; assert_eq!(1, left.point(1)); assert_eq!(1, ri...
{ let mut left = Sketch::new(0.0001, 0.99); let mut right = Sketch::new(0.0001, 0.99); left.add(1); right.add(1); let mut third = &left + &right; third.point(1); }
identifier_body
addition.rs
extern crate basiccms; #[cfg(test)] mod tests { use basiccms::*; #[test] #[should_panic] fn
() { let mut left = Sketch::new(0.0001, 0.99); let mut right = Sketch::new(0.0001, 0.99); left.add(1); right.add(1); let mut third = &left + &right; third.point(1); } #[test] fn but_you_can_add_together_two_sketches_from_a_common_base () { let mut left ...
you_cannot_add_two_sketches_together_if_they_have_different_hashers
identifier_name
quote-tokens.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
#![feature(quote, rustc_private)] extern crate syntax; use syntax::ext::base::ExtCtxt; use syntax::ptr::P; fn syntax_extension(cx: &ExtCtxt) { let e_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, 1 + 2); let p_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, (x, 1.. 4, *)); let a: P<synta...
// ignore-pretty: does not work well with `--test`
random_line_split
quote-tokens.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(cx: &ExtCtxt) { let e_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, 1 + 2); let p_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, (x, 1.. 4, *)); let a: P<syntax::ast::Expr> = quote_expr!(cx, 1 + 2); let _b: Option<P<syntax::ast::Item>> = quote_item!(cx, static foo : isize = $e_toks; )...
syntax_extension
identifier_name
quote-tokens.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ }
identifier_body
tree_id.rs
use std::cmp::Ordering; #[derive(Debug, Clone)] pub struct TreeId { id: String } static TREE_ID_STEP: usize = 2; impl TreeId { pub fn new(s: String) -> Self { TreeId { id: s } } pub fn id(&self) -> String { self.id.clone() } pub fn len(&self) -> usize { ...
} impl Eq for TreeId {} impl PartialEq for TreeId { fn eq(&self, other: &TreeId) -> bool { self.id == other.id } } pub fn level(ti: &TreeId) -> usize { ti.id.len() / TREE_ID_STEP } pub fn key(ti: &TreeId, level: usize) -> Option<String> { let sub_index = level*TREE_ID_STEP; let ref s = ...
{ Some(self.id.cmp(&other.id)) }
identifier_body
tree_id.rs
use std::cmp::Ordering; #[derive(Debug, Clone)] pub struct TreeId { id: String } static TREE_ID_STEP: usize = 2; impl TreeId { pub fn new(s: String) -> Self { TreeId { id: s } } pub fn id(&self) -> String { self.id.clone() } pub fn len(&self) -> usize { ...
(&self, other: &TreeId) -> Option<Ordering> { Some(self.id.cmp(&other.id)) } } impl Eq for TreeId {} impl PartialEq for TreeId { fn eq(&self, other: &TreeId) -> bool { self.id == other.id } } pub fn level(ti: &TreeId) -> usize { ti.id.len() / TREE_ID_STEP } pub fn key(ti: &TreeId, le...
partial_cmp
identifier_name
tree_id.rs
use std::cmp::Ordering; #[derive(Debug, Clone)] pub struct TreeId { id: String } static TREE_ID_STEP: usize = 2; impl TreeId { pub fn new(s: String) -> Self { TreeId { id: s } } pub fn id(&self) -> String { self.id.clone() } pub fn len(&self) -> usize { ...
} } impl PartialOrd for TreeId { fn partial_cmp(&self, other: &TreeId) -> Option<Ordering> { Some(self.id.cmp(&other.id)) } } impl Eq for TreeId {} impl PartialEq for TreeId { fn eq(&self, other: &TreeId) -> bool { self.id == other.id } } pub fn level(ti: &TreeId) -> usize { ...
self.id.cmp(&other.id)
random_line_split
tree_id.rs
use std::cmp::Ordering; #[derive(Debug, Clone)] pub struct TreeId { id: String } static TREE_ID_STEP: usize = 2; impl TreeId { pub fn new(s: String) -> Self { TreeId { id: s } } pub fn id(&self) -> String { self.id.clone() } pub fn len(&self) -> usize { ...
else if sub_index < s.len() { Some(String::from(&s[..sub_index])) } else { None } }
{ Some(s.clone()) }
conditional_block
metadata.rs
// Copyright 2017 CoreOS, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
"aws" => box_result!(AwsProvider::try_new()?), "azure" => box_result!(Azure::try_new()?), "cloudstack-metadata" => box_result!(CloudstackNetwork::try_new()?), "cloudstack-configdrive" => box_result!(ConfigDrive::try_new()?), "digitalocean" => box_result!(DigitalOceanProvider::try...
pub fn fetch_metadata(provider: &str) -> errors::Result<Box<dyn providers::MetadataProvider>> { match provider { "aliyun" => box_result!(AliyunProvider::try_new()?), #[cfg(not(feature = "cl-legacy"))]
random_line_split
metadata.rs
// Copyright 2017 CoreOS, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
(provider: &str) -> errors::Result<Box<dyn providers::MetadataProvider>> { match provider { "aliyun" => box_result!(AliyunProvider::try_new()?), #[cfg(not(feature = "cl-legacy"))] "aws" => box_result!(AwsProvider::try_new()?), "azure" => box_result!(Azure::try_new()?), "cloud...
fetch_metadata
identifier_name
metadata.rs
// Copyright 2017 CoreOS, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
"openstack" => openstack::try_config_drive_else_network(), "openstack-metadata" => box_result!(OpenstackProviderNetwork::try_new()?), "packet" => box_result!(PacketProvider::try_new()?), #[cfg(feature = "cl-legacy")] "vagrant-virtualbox" => box_result!(VagrantVirtualboxProvider::...
{ match provider { "aliyun" => box_result!(AliyunProvider::try_new()?), #[cfg(not(feature = "cl-legacy"))] "aws" => box_result!(AwsProvider::try_new()?), "azure" => box_result!(Azure::try_new()?), "cloudstack-metadata" => box_result!(CloudstackNetwork::try_new()?), "c...
identifier_body
lib.rs
// This thread waits for requests to calculate the currently visible nodes, runs a // calculation and sends the visible nodes back to the drawing thread. If multiple requests // queue up while it is processing one, it will drop all but the latest one before // restarting the next calculation...
else { self.max_nodes_in_memory }; let filtered_visible_nodes = self.visible_nodes.iter().take(max_nodes_to_display); for node_id in filtered_visible_nodes { let view = self.node_views.get_or_request(&node_id); if!self.needs_drawing || view.is_none() { ...
{ self.max_nodes_moving }
conditional_block
lib.rs
// This thread waits for requests to calculate the currently visible nodes, runs a // calculation and sends the visible nodes back to the drawing thread. If multiple requests // queue up while it is processing one, it will drop all but the latest one before // restarting the next calculation...
pub trait Extension { fn pre_init(app: clap::App) -> clap::App; fn new(matches: &clap::ArgMatches, opengl: Rc<opengl::Gl>) -> Self; fn local_from_global(matches: &clap::ArgMatches, octree: &Octree) -> Option<Isometry3<f64>>; fn camera_changed(&mut self, transform: &Matrix4<f64>); fn draw(&mut self...
{ if pose_path.is_none() { eprintln!("Not serving from a local directory. Cannot load camera."); return; } assert!(index < 10); let states = ::std::fs::read_to_string(pose_path.as_ref().unwrap()) .and_then(|data| { serde_json::from_str(&data) .map_err(...
identifier_body
lib.rs
{ gl: Rc<opengl::Gl>, node_drawer: NodeDrawer, last_moving: time::Instant, // TODO(sirver): Logging does not fit into this classes responsibilities. last_log: time::Instant, visible_nodes: Vec<octree::NodeId>, get_visible_nodes_params_tx: mpsc::Sender<Matrix4<f64>>, get_visible_nodes_re...
PointCloudRenderer
identifier_name
lib.rs
pub mod box_drawer; pub mod graphic; pub mod node_drawer; pub mod terrain_drawer; use crate::box_drawer::BoxDrawer; use crate::camera::Camera; use crate::node_drawer::{NodeDrawer, NodeViewContainer}; use crate::terrain_drawer::TerrainRenderer; use nalgebra::{Isometry3, Matrix4}; use point_viewer::color::YELLOW; use po...
#[rustversion::attr(since(1.45), allow(clippy::manual_non_exhaustive))] pub mod opengl { include!(concat!(env!("OUT_DIR"), "/bindings.rs")); }
random_line_split
problem-022.rs
// Copyright 2016 Peter Beard // Distributed under the GNU GPL v2. For full terms, see the LICENSE file. // // Using names.txt (right click and 'Save Link/Target As...'), a 46K text // file containing over five-thousand first names, begin by sorting it into // alphabetical order. Then working out the alphabetical value...
b: &mut Bencher) { b.iter(|| solution("../data/p022_names.txt")); } }
ench(
identifier_name
problem-022.rs
// Copyright 2016 Peter Beard // Distributed under the GNU GPL v2. For full terms, see the LICENSE file. // // Using names.txt (right click and 'Save Link/Target As...'), a 46K text // file containing over five-thousand first names, begin by sorting it into // alphabetical order. Then working out the alphabetical value...
}
b.iter(|| solution("../data/p022_names.txt")); }
identifier_body
problem-022.rs
// Copyright 2016 Peter Beard // Distributed under the GNU GPL v2. For full terms, see the LICENSE file. // // Using names.txt (right click and 'Save Link/Target As...'), a 46K text // file containing over five-thousand first names, begin by sorting it into // alphabetical order. Then working out the alphabetical value...
} } s } pub fn solution(data_file: &str) -> u32 { let f = match File::open(data_file) { Ok(file) => file, Err(e) => panic!("Failed to read file: {}", e) }; let mut reader = BufReader::new(f); // We're only interested in the first line let mut line = String::new(); ...
let mut s = 0; for c in name.chars() { if c.is_alphabetic() { s += c as u32 - 64;
random_line_split
kind.rs
use std::convert::TryInto; use std::fmt; use crate::mir::interpret::{AllocId, ConstValue, Scalar}; use crate::mir::Promoted; use crate::ty::subst::{InternalSubsts, SubstsRef}; use crate::ty::ParamEnv; use crate::ty::{self, TyCtxt, TypeFoldable}; use rustc_errors::ErrorReported; use rustc_hir::def_id::DefId; use rustc_...
(self) -> Option<bool> { self.try_to_scalar_int()?.try_into().ok() } #[inline] pub fn try_to_machine_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64> { self.try_to_value()?.try_to_machine_usize(tcx) } } /// An inference variable for a const, for use in const generics. #[derive(Copy, Clone...
try_to_bool
identifier_name
kind.rs
use std::convert::TryInto; use std::fmt; use crate::mir::interpret::{AllocId, ConstValue, Scalar}; use crate::mir::Promoted; use crate::ty::subst::{InternalSubsts, SubstsRef}; use crate::ty::ParamEnv; use crate::ty::{self, TyCtxt, TypeFoldable}; use rustc_errors::ErrorReported; use rustc_hir::def_id::DefId; use rustc_...
// `ty::ParamEnvAnd` instead of having them separate. let (param_env, unevaluated) = param_env_and.into_parts(); // try to resolve e.g. associated constants to their definition on an impl, and then // evaluate the const. match tcx.const_eval_resolve(param_env,...
}; // FIXME(eddyb) maybe the `const_eval_*` methods should take
random_line_split
kind.rs
use std::convert::TryInto; use std::fmt; use crate::mir::interpret::{AllocId, ConstValue, Scalar}; use crate::mir::Promoted; use crate::ty::subst::{InternalSubsts, SubstsRef}; use crate::ty::ParamEnv; use crate::ty::{self, TyCtxt, TypeFoldable}; use rustc_errors::ErrorReported; use rustc_hir::def_id::DefId; use rustc_...
} impl<'tcx> Unevaluated<'tcx, ()> { #[inline] pub fn expand(self) -> Unevaluated<'tcx> { Unevaluated { def: self.def, substs_: self.substs_, promoted: None } } } impl<'tcx, P: Default> Unevaluated<'tcx, P> { #[inline] pub fn new(def: ty::WithOptConstParam<DefId>, substs: SubstsRef<'tcx>)...
{ debug_assert_eq!(self.promoted, None); Unevaluated { def: self.def, substs_: self.substs_, promoted: () } }
identifier_body
htmlmeterelement.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::HTMLMeterElementBinding::{self, HTMLMeterElementMethods}; use dom::bindings:...
(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> DomRoot<HTMLMeterElement> { Node::reflect_node(box HTMLMeterElement::new_inherited(local_name, prefix, document), document, HTMLMeterElementBinding::Wrap) ...
new
identifier_name
htmlmeterelement.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::HTMLMeterElementBinding::{self, HTMLMeterElementMethods}; use dom::bindings:...
#[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> DomRoot<HTMLMeterElement> { Node::reflect_node(box HTMLMeterElement::new_inherited(local_name, prefix, document), document, ...
}
random_line_split
tunnel_client.rs
#[macro_use] extern crate log; extern crate env_logger; extern crate mig; use std::sync::{Arc}; use std::io::{Read, Write}; use std::net::TcpListener; use std::str; use std::thread; use mig::quic::threaded::QuicConnection; fn main() { env_logger::init().unwrap(); let args = ::std::env::args; if args()...
, }; info!("Server on {}: listening for connections...", address); loop { let (mut connection, _) = match listener.accept() { Ok(connection) => { connection }, Err(e) => { error!("Cannot accept a connection: {}", e); ...
{ error!("Cannot bind to the address: {}", e); return; }
conditional_block
tunnel_client.rs
#[macro_use] extern crate log; extern crate env_logger; extern crate mig; use std::sync::{Arc}; use std::io::{Read, Write}; use std::net::TcpListener; use std::str;
use mig::quic::threaded::QuicConnection; fn main() { env_logger::init().unwrap(); let args = ::std::env::args; if args().len()!= 3 || args().nth(1) == Some("--help".to_string()) { println!("Usage: tunnel_client <serverip>:<port> <targetip>:<port>"); return; } let address = args(...
use std::thread;
random_line_split
tunnel_client.rs
#[macro_use] extern crate log; extern crate env_logger; extern crate mig; use std::sync::{Arc}; use std::io::{Read, Write}; use std::net::TcpListener; use std::str; use std::thread; use mig::quic::threaded::QuicConnection; fn
() { env_logger::init().unwrap(); let args = ::std::env::args; if args().len()!= 3 || args().nth(1) == Some("--help".to_string()) { println!("Usage: tunnel_client <serverip>:<port> <targetip>:<port>"); return; } let address = args().nth(1).unwrap(); let target = args().nth(2).u...
main
identifier_name
tunnel_client.rs
#[macro_use] extern crate log; extern crate env_logger; extern crate mig; use std::sync::{Arc}; use std::io::{Read, Write}; use std::net::TcpListener; use std::str; use std::thread; use mig::quic::threaded::QuicConnection; fn main()
}; info!("Server on {}: listening for connections...", address); loop { let (mut connection, _) = match listener.accept() { Ok(connection) => { connection }, Err(e) => { error!("Cannot accept a connection: {}", e); ...
{ env_logger::init().unwrap(); let args = ::std::env::args; if args().len() != 3 || args().nth(1) == Some("--help".to_string()) { println!("Usage: tunnel_client <serverip>:<port> <targetip>:<port>"); return; } let address = args().nth(1).unwrap(); let target = args().nth(2).unw...
identifier_body
task-comm-14.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 (p, ch) = comm::stream(); po.add(p); task::spawn({let i = i; || child(i, &ch)}); i = i - 1; } // Spawned tasks are likely killed before they get a chance to send // anything back, so we deadlock here. i = 10; while (i > 0) { debug!(i); po.recv();...
while (i > 0) { debug!(i);
random_line_split
task-comm-14.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(x: int, ch: &comm::Chan<int>) { debug!(x); ch.send(x); }
child
identifier_name
task-comm-14.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 = i - 1; } debug!("main thread exiting"); } fn child(x: int, ch: &comm::Chan<int>) { debug!(x); ch.send(x); }
{ let po = comm::PortSet(); // Spawn 10 tasks each sending us back one int. let mut i = 10; while (i > 0) { debug!(i); let (p, ch) = comm::stream(); po.add(p); task::spawn({let i = i; || child(i, &ch)}); i = i - 1; } // Spawned tasks are likely killed be...
identifier_body
camera_calibration.rs
use {Cmcs, Point, Result}; use std::path::Path; /// A camera calibration. /// /// Only opencv camera calibrations are supported at this time. #[derive(Clone, Debug, PartialEq, Serialize)] #[allow(missing_docs)] pub struct CameraCalibration { /// The name of the calibration. pub name: String, pub cx: f64, ...
() { let camera_calibration = CameraCalibration::from_project_path("data/southpole.rsp") .unwrap() .pop() .unwrap(); assert!(camera_calibration.is_valid_pixel(0, 0)); assert!(!camera_calibration.is_valid_pixel(-1, 0)); assert!(!camera_calibration.is_valid...
is_valid_pixel
identifier_name
camera_calibration.rs
use {Cmcs, Point, Result}; use std::path::Path; /// A camera calibration. /// /// Only opencv camera calibrations are supported at this time. #[derive(Clone, Debug, PartialEq, Serialize)] #[allow(missing_docs)] pub struct CameraCalibration { /// The name of the calibration. pub name: String, pub cx: f64, ...
let a = Matrix3::new(self.fx, 0., self.cx, 0., self.fy, self.cy, 0., 0., 1.); let ud_prime = a * point.deref(); let u = ud_prime[0] / ud_prime[2]; let v = ud_prime[1] / ud_prime[2]; let x = (u - self.cx) / self.fx; let y = (v - self.cy) / self.fy; let r = (x.pow...
{ return None; }
conditional_block
camera_calibration.rs
use {Cmcs, Point, Result}; use std::path::Path; /// A camera calibration. /// /// Only opencv camera calibrations are supported at this time. #[derive(Clone, Debug, PartialEq, Serialize)] #[allow(missing_docs)] pub struct CameraCalibration { /// The name of the calibration. pub name: String, pub cx: f64, ...
} #[cfg(test)] mod tests { use super::*; #[test] fn cmcs_to_ics() { let camera_calibration = CameraCalibration::from_project_path("data/southpole.rsp") .unwrap() .pop() .unwrap(); let cmcs = Point::cmcs(1.312, -0.641, 3.019); let (u, v) = camera_ca...
{ let u = u.into(); let v = v.into(); u >= 0. && v >= 0. && u < self.width as f64 && v < self.height as f64 }
identifier_body
camera_calibration.rs
use {Cmcs, Point, Result}; use std::path::Path; /// A camera calibration. /// /// Only opencv camera calibrations are supported at this time. #[derive(Clone, Debug, PartialEq, Serialize)] #[allow(missing_docs)] pub struct CameraCalibration { /// The name of the calibration. pub name: String, pub cx: f64, ...
} impl CameraCalibration { /// Retrieves all camera calibrations from a project. /// /// # Examples /// /// ``` /// use riscan_pro::CameraCalibration; /// let camera_calibrations = CameraCalibration::from_project_path("data/project.RiSCAN") /// .unwrap(); /// assert_eq!(1, camera...
pub tan_max_vert: f64, pub tan_min_horz: f64, pub tan_min_vert: f64, pub width: usize, pub height: usize,
random_line_split
shared_vec_slice.rs
use std::sync::Arc; #[derive(Clone)] pub struct SharedVecSlice { pub data: Arc<Vec<u8>>, pub start: usize, pub len: usize, } impl SharedVecSlice { pub fn empty() -> SharedVecSlice { SharedVecSlice::new(Arc::new(Vec::new())) } pub fn new(data: Arc<Vec<u8>>) -> SharedVecSlice { ...
pub fn slice(&self, from_offset: usize, to_offset: usize) -> SharedVecSlice { SharedVecSlice { data: self.data.clone(), start: self.start + from_offset, len: to_offset - from_offset, } } }
}
random_line_split
shared_vec_slice.rs
use std::sync::Arc; #[derive(Clone)] pub struct SharedVecSlice { pub data: Arc<Vec<u8>>, pub start: usize, pub len: usize, } impl SharedVecSlice { pub fn empty() -> SharedVecSlice { SharedVecSlice::new(Arc::new(Vec::new())) } pub fn new(data: Arc<Vec<u8>>) -> SharedVecSlice { ...
pub fn slice(&self, from_offset: usize, to_offset: usize) -> SharedVecSlice { SharedVecSlice { data: self.data.clone(), start: self.start + from_offset, len: to_offset - from_offset, } } }
{ &self.data[self.start..self.start + self.len] }
identifier_body
shared_vec_slice.rs
use std::sync::Arc; #[derive(Clone)] pub struct SharedVecSlice { pub data: Arc<Vec<u8>>, pub start: usize, pub len: usize, } impl SharedVecSlice { pub fn empty() -> SharedVecSlice { SharedVecSlice::new(Arc::new(Vec::new())) } pub fn new(data: Arc<Vec<u8>>) -> SharedVecSlice { ...
(&self) -> &[u8] { &self.data[self.start..self.start + self.len] } pub fn slice(&self, from_offset: usize, to_offset: usize) -> SharedVecSlice { SharedVecSlice { data: self.data.clone(), start: self.start + from_offset, len: to_offset - from_offset, }...
as_slice
identifier_name
lib.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
pub mod macro_parser; pub mod macro_rules; pub mod quoted; } } #[cfg(test)] mod test_snippet; // __build_diagnostic_array! { libsyntax, DIAGNOSTICS }
pub mod source_util; pub mod tt { pub mod transcribe;
random_line_split
url.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Common handling for the specified value CSS url() values. use cssparser::Parser; use gecko_bindings::bindings...
(url: String, context: &ParserContext) -> Self { CssUrl(Arc::new(CssUrlData { serialization: url, extra_data: context.url_data.clone(), })) } /// Returns true if the URL is definitely invalid. We don't eagerly resolve /// URLs in gecko, so we just return false here. ...
parse_from_string
identifier_name
url.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Common handling for the specified value CSS url() values. use cssparser::Parser; use gecko_bindings::bindings...
self.url.eq(&other.url) } } impl Eq for SpecifiedUrl {} impl MallocSizeOf for SpecifiedUrl { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { let mut n = self.url.size_of(ops); // Although this is a RefPtr, this is the primary reference because // SpecifiedUrl is respons...
} impl PartialEq for SpecifiedUrl { fn eq(&self, other: &Self) -> bool {
random_line_split
lib.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
(signature: &Signature, public_key: &PublicKey, claim: &SerialisedClaim) -> Option<SerialisedClaim> { match crypto::sign::verify_detached(&signature, claim, public_key) { true => Some(claim.clone()), false => None, } }
verify_signature
identifier_name
lib.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
private_no_mangle_fns, private_no_mangle_statics, raw_pointer_derive, stable_features, unconditional_recursion, unknown_lints, unsafe_code, unused, unused_allocation, unused_attributes, unused_comparisons, unused_features, unused_parens, while_true)] #![warn(trivial_casts, trivial_numeric_casts,...
// https://github.com/maidsafe/QA/blob/master/Documentation/Rust%20Lint%20Checks.md #![forbid(bad_style, exceeding_bitshifts, mutable_transmutes, no_mangle_const_items, unknown_crate_types, warnings)] #![deny(deprecated, drop_with_repr_extern, improper_ctypes, missing_docs, non_shorthand_field_pattern...
random_line_split
lib.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
{ match crypto::sign::verify_detached(&signature, claim, public_key) { true => Some(claim.clone()), false => None, } }
identifier_body
cargo_clean.rs
use std::default::Default; use std::fs; use std::path::Path; use core::{Package, Profiles}; use core::source::Source; use util::{CargoResult, human, ChainError, Config}; use ops::{self, Layout, Context, BuildConfig, Kind, Unit}; pub struct CleanOptions<'a> { pub spec: &'a [String], pub target: Option<&'a str>...
; let host_layout = Layout::new(opts.config, &root, None, dest); let target_layout = opts.target.map(|target| { Layout::new(opts.config, &root, Some(target), dest) }); let cx = try!(Context::new(&resolve, &packages, opts.config, host_layout, target_layout, ...
{"debug"}
conditional_block
cargo_clean.rs
use std::default::Default; use std::fs; use std::path::Path; use core::{Package, Profiles}; use core::source::Source; use util::{CargoResult, human, ChainError, Config}; use ops::{self, Layout, Context, BuildConfig, Kind, Unit}; pub struct CleanOptions<'a> { pub spec: &'a [String], pub target: Option<&'a str>...
} let (resolve, packages) = try!(ops::fetch(manifest_path, opts.config)); let dest = if opts.release {"release"} else {"debug"}; let host_layout = Layout::new(opts.config, &root, None, dest); let target_layout = opts.target.map(|target| { Layout::new(opts.config, &root, Some(target), dest)...
// remove the whole target directory and be done with it! if opts.spec.is_empty() { return rm_rf(&target_dir);
random_line_split
cargo_clean.rs
use std::default::Default; use std::fs; use std::path::Path; use core::{Package, Profiles}; use core::source::Source; use util::{CargoResult, human, ChainError, Config}; use ops::{self, Layout, Context, BuildConfig, Kind, Unit}; pub struct
<'a> { pub spec: &'a [String], pub target: Option<&'a str>, pub config: &'a Config, pub release: bool, } /// Cleans the project from build artifacts. pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> { let root = try!(Package::for_path(manifest_path, opts.config)); let ...
CleanOptions
identifier_name
cargo_clean.rs
use std::default::Default; use std::fs; use std::path::Path; use core::{Package, Profiles}; use core::source::Source; use util::{CargoResult, human, ChainError, Config}; use ops::{self, Layout, Context, BuildConfig, Kind, Unit}; pub struct CleanOptions<'a> { pub spec: &'a [String], pub target: Option<&'a str>...
BuildConfig::default(), root.manifest().profiles())); // resolve package specs and remove the corresponding packages for spec in opts.spec { // Translate the spec to a Package let pkgid = try!(resolve.query(spec)); let pkg = ...
{ let root = try!(Package::for_path(manifest_path, opts.config)); let target_dir = opts.config.target_dir(&root); // If we have a spec, then we need to delete some packages, otherwise, just // remove the whole target directory and be done with it! if opts.spec.is_empty() { return rm_rf(&tar...
identifier_body
serviceworkerregistration.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::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ServiceWorkerBinding::Se...
(&self) -> USVString { USVString(self.scope.as_str().to_owned()) } // https://w3c.github.io/ServiceWorker/#service-worker-registration-updateviacache fn UpdateViaCache(&self) -> ServiceWorkerUpdateViaCache { self.update_via_cache } // https://w3c.github.io/ServiceWorker/#service-wo...
Scope
identifier_name
serviceworkerregistration.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::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ServiceWorkerBinding::Se...
else { self.active.as_ref().map(|sw| DomRoot::from_ref(&**sw)) } } } pub fn longest_prefix_match(stored_scope: &ServoUrl, potential_match: &ServoUrl) -> bool { if stored_scope.origin()!= potential_match.origin() { return false; } let scope_chars = stored_scope.path().chars(...
{ self.waiting.as_ref().map(|sw| DomRoot::from_ref(&**sw)) }
conditional_block
serviceworkerregistration.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::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ServiceWorkerBinding::Se...
impl ServiceWorkerRegistrationMethods for ServiceWorkerRegistration { // https://w3c.github.io/ServiceWorker/#service-worker-registration-installing-attribute fn GetInstalling(&self) -> Option<DomRoot<ServiceWorker>> { self.installing.as_ref().map(|sw| DomRoot::from_ref(&**sw)) } // https://w...
{ if stored_scope.origin() != potential_match.origin() { return false; } let scope_chars = stored_scope.path().chars(); let matching_chars = potential_match.path().chars(); if scope_chars.count() > matching_chars.count() { return false; } stored_scope .path() ...
identifier_body
serviceworkerregistration.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::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ServiceWorkerBinding::Se...
pub fn set_navigation_preload_header_value(&self, value: ByteString) { let mut header_value = self.navigation_preload_header_value.borrow_mut(); *header_value = Some(value); } pub fn get_navigation_preload_enabled(&self) -> bool { self.navigation_preload_enabled.get() } pu...
pub fn get_navigation_preload_header_value(&self) -> Option<ByteString> { self.navigation_preload_header_value.borrow().clone() }
random_line_split
graphics.rs
use editor::Editor; use orbital::Color; use redraw::RedrawTask; use mode::Mode; use mode::PrimitiveMode; use mode::CommandMode; impl Editor { /// Redraw the window pub fn redraw(&mut self) { // TODO: Only draw when relevant for the window let (mut pos_x, pos_y) = self.pos(); // Redraw w...
(editor: &mut Editor, text: String, a: usize, b: usize) { let h = editor.window.height(); let w = editor.window.width(); // let y = editor.y(); let mode = editor.cursor().mode; for (n, c) in (if text.len() > w / (8 * b) { text.chars().take(w / (8 * b) - 5).chain(vec!['.'; 3])...
status_bar
identifier_name
graphics.rs
use editor::Editor; use orbital::Color; use redraw::RedrawTask; use mode::Mode; use mode::PrimitiveMode; use mode::CommandMode; impl Editor { /// Redraw the window pub fn redraw(&mut self) { // TODO: Only draw when relevant for the window let (mut pos_x, pos_y) = self.pos(); // Redraw w...
status_bar(self, sb_file, 1, 4); let sb_cmd = self.status_bar.cmd.clone(); status_bar(self, sb_cmd, 2, 4); let sb_msg = self.status_bar.msg.clone(); status_bar(self, sb_msg, 3, 4); for (n, c) in self.prompt.chars().enumerate() { self.window.char(n as isize * ...
{ let h = self.window.height(); let w = self.window.width(); let mode = self.cursor().mode; self.window.rect(0, h as isize - 18 - { if mode == Mode::Primitive(PrimitiveMode::Prompt) { ...
identifier_body
graphics.rs
use editor::Editor; use orbital::Color; use redraw::RedrawTask; use mode::Mode; use mode::PrimitiveMode; use mode::CommandMode; impl Editor { /// Redraw the window pub fn redraw(&mut self) { // TODO: Only draw when relevant for the window let (mut pos_x, pos_y) = self.pos(); // Redraw w...
_ if string => (226, 225, 167), //(167, 222, 156) '!' | '@' | '#' | '$' | '%' | '^' | '&' | '|' | ...
{ string = !string; (226, 225, 167) //(167, 222, 156) }
conditional_block
graphics.rs
use editor::Editor; use orbital::Color; use redraw::RedrawTask; use mode::Mode; use mode::PrimitiveMode; use mode::CommandMode; impl Editor { /// Redraw the window pub fn redraw(&mut self) { // TODO: Only draw when relevant for the window let (mut pos_x, pos_y) = self.pos(); // Redraw w...
let sb_msg = self.status_bar.msg.clone(); status_bar(self, sb_msg, 3, 4); for (n, c) in self.prompt.chars().enumerate() { self.window.char(n as isize * 8, h as isize - 16 - 1, c, Color::WHITE); } self.window.sync(); } } fn status_bar(editor: &mut Editor, text: ...
let sb_cmd = self.status_bar.cmd.clone(); status_bar(self, sb_cmd, 2, 4);
random_line_split
running-with-no-runtime.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { let args = os::args(); let me = args.get(0).as_slice(); let x: &[u8] = &[1u8]; pass(Command::new(me).arg(x).output().unwrap()); let x: &[u8] = &[2u8]; pass(Command::new(me).arg(x).output().unwrap()); let x: &[u8] = &[3u8]; pass(Command::new(me).arg(x).output().unwrap()); ...
{ if argc > 1 { unsafe { match **argv.offset(1) { 1 => {} 2 => println!("foo"), 3 => assert!(try(|| {}).is_ok()), 4 => assert!(try(|| fail!()).is_err()), 5 => assert!(try(|| spawn(proc() {})).is_err()), ...
identifier_body
running-with-no-runtime.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 ...
pass(Command::new(me).arg(x).output().unwrap()); let x: &[u8] = &[4u8]; pass(Command::new(me).arg(x).output().unwrap()); let x: &[u8] = &[5u8]; pass(Command::new(me).arg(x).output().unwrap()); let x: &[u8] = &[6u8]; pass(Command::new(me).arg(x).output().unwrap()); let x: &[u8] = &[7u8]; ...
pass(Command::new(me).arg(x).output().unwrap()); let x: &[u8] = &[3u8];
random_line_split
running-with-no-runtime.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 ...
(output: ProcessOutput) { if!output.status.success() { println!("{}", str::from_utf8(output.output.as_slice())); println!("{}", str::from_utf8(output.error.as_slice())); } }
pass
identifier_name
twoBitFreq.rs
// Implement twoBitFreq in Rust extern crate twobit; use twobit::TwoBit; use std::error::Error; fn main() { let mut args = std::env::args(); if args.len()!= 3 { println!("Usage: {} <2bit filename> <name> ", args.next().unwrap()); } else {
let filename = args.next().unwrap(); let chrom = args.next().unwrap(); let tb = TwoBit::new(&filename); match tb { Ok(tbv) => { match tbv.base_frequencies(&chrom) { Some(freqs) => println!("{} base frequencies (ACGT): {} {} {} {}", chrom, freqs[0], freqs[1], freqs[2], freqs[3]), ...
let mut args = args.skip(1);
random_line_split
twoBitFreq.rs
// Implement twoBitFreq in Rust extern crate twobit; use twobit::TwoBit; use std::error::Error; fn
() { let mut args = std::env::args(); if args.len()!= 3 { println!("Usage: {} <2bit filename> <name> ", args.next().unwrap()); } else { let mut args = args.skip(1); let filename = args.next().unwrap(); let chrom = args.next().unwrap(); let tb = TwoBit::new(&filename); match tb { Ok(tbv) => { ...
main
identifier_name
twoBitFreq.rs
// Implement twoBitFreq in Rust extern crate twobit; use twobit::TwoBit; use std::error::Error; fn main()
Err(ioerr) => println!("{}: {}", ioerr.description(), filename) } } }
{ let mut args = std::env::args(); if args.len() != 3 { println!("Usage: {} <2bit filename> <name> ", args.next().unwrap()); } else { let mut args = args.skip(1); let filename = args.next().unwrap(); let chrom = args.next().unwrap(); let tb = TwoBit::new(&filename); match tb { Ok(tbv) => { ma...
identifier_body
html.rs
use cw::{Crosswords, Dir, Point, PrintItem}; use std::collections::HashMap; use std::io::{Result, Write}; const CSS: &'static str = r#" .solution { font: 22px monospace; text-align: center; position: absolute; left: 0px; right: 0px; bottom: 0px; } .hint { font: 8px monospace; color: Gra...
} } try!(writeln!(writer, "</p>")); Ok(()) } /// Write the crosswords to the given writer as an HTML page. pub fn write_html<T: Write>(writer: &mut T, cw: &Crosswords, solution: bool, hint_text: &HashMap<String, St...
{ let word: String = cw.chars_at(p, dir).collect(); let hint = hint_text .get(&word) .cloned() .unwrap_or_else(|| format!("[{}]", word)); try!(write!(writer, "<b>{}.</b> {} &nbsp;", hint_count, hint)); ...
conditional_block
html.rs
use cw::{Crosswords, Dir, Point, PrintItem}; use std::collections::HashMap; use std::io::{Result, Write}; const CSS: &'static str = r#" .solution { font: 22px monospace; text-align: center; position: absolute; left: 0px; right: 0px; bottom: 0px; } .hint { font: 8px monospace; color: Gra...
.light { background-color: LightGray; } .blockcol { background-color: DarkBlue; } "#; fn get_border_class(border: bool) -> &'static str { if border { "dark" } else { "light" } } fn string_for(item: &PrintItem, solution: bool) -> String { match *item { PrintItem::HorizBorder(b) | PrintItem::Cro...
random_line_split
html.rs
use cw::{Crosswords, Dir, Point, PrintItem}; use std::collections::HashMap; use std::io::{Result, Write}; const CSS: &'static str = r#" .solution { font: 22px monospace; text-align: center; position: absolute; left: 0px; right: 0px; bottom: 0px; } .hint { font: 8px monospace; color: Gra...
fn write_hints<T: Write>(writer: &mut T, cw: &Crosswords, dir: Dir, hint_text: &HashMap<String, String>) -> Result<()> { try!(writeln!(writer, "<p><br><b>{}:</b>&nbsp;", match di...
{ try!(writeln!(writer, r#"<div class="row">"#)); for item in items { try!(writer.write_all(string_for(&item, solution).as_bytes())) } try!(writeln!(writer, "</div>")); Ok(()) }
identifier_body
html.rs
use cw::{Crosswords, Dir, Point, PrintItem}; use std::collections::HashMap; use std::io::{Result, Write}; const CSS: &'static str = r#" .solution { font: 22px monospace; text-align: center; position: absolute; left: 0px; right: 0px; bottom: 0px; } .hint { font: 8px monospace; color: Gra...
<T: Write>(writer: &mut T, cw: &Crosswords, dir: Dir, hint_text: &HashMap<String, String>) -> Result<()> { try!(writeln!(writer, "<p><br><b>{}:</b>&nbsp;", match dir { ...
write_hints
identifier_name
reexported-static-methods-cross-crate.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ assert_eq!(42, Foo::foo()); assert_eq!(84, Baz::bar()); assert!(Boz::boz(1)); assert_eq!("bort()".to_string(), Bort::bort()); }
identifier_body
reexported-static-methods-cross-crate.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
assert!(Boz::boz(1)); assert_eq!("bort()".to_string(), Bort::bort()); }
random_line_split
reexported-static-methods-cross-crate.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { assert_eq!(42, Foo::foo()); assert_eq!(84, Baz::bar()); assert!(Boz::boz(1)); assert_eq!("bort()".to_string(), Bort::bort()); }
main
identifier_name
regions-return-interior-of-option.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 mut x = Some(23i); { let y = get(&x); assert_eq!(*y, 23); } x = Some(24i); { let y = get(&x); assert_eq!(*y, 24); } }
identifier_body
regions-return-interior-of-option.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } pub fn main() { let mut x = Some(23i); { let y = get(&x); assert_eq!(*y, 23); } x = Some(24i); { let y = get(&x); assert_eq!(*y, 24); } }
random_line_split
regions-return-interior-of-option.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 ...
<T>(opt: &Option<T>) -> &T { match *opt { Some(ref v) => v, None => fail!("none") } } pub fn main() { let mut x = Some(23i); { let y = get(&x); assert_eq!(*y, 23); } x = Some(24i); { let y = get(&x); assert_eq!(*y, 24); } }
get
identifier_name
build.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> extern crate gcc; extern crate pkg_config; use std::ascii::AsciiExt; use std::process::C...
() { let lib = pkg_config::find_library("gtk+-3.0") .unwrap_or_else(|e| panic!("{}", e)); let mut parts = lib.version.splitn(3, '.') .map(|s| s.parse()) .take_while(|r| r.is_ok()) .map(|r| r.unwrap()); let version: (u16, u16) = (parts.next().unwrap_or(0), parts.next().unwrap_or(0...
main
identifier_name
build.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> extern crate gcc; extern crate pkg_config; use std::ascii::AsciiExt; use std::process::C...
println!("cargo:cfg={}", cfgs.connect(" ")); env::set_var("PKG_CONFIG_ALLOW_CROSS", "1"); // call native pkg-config, there is no way to do this with pkg-config for now let cmd = Command::new("pkg-config").arg("--cflags").arg("gtk+-3.0") .output().unwrap(); if!cmd.status.success() { ...
{ let lib = pkg_config::find_library("gtk+-3.0") .unwrap_or_else(|e| panic!("{}", e)); let mut parts = lib.version.splitn(3, '.') .map(|s| s.parse()) .take_while(|r| r.is_ok()) .map(|r| r.unwrap()); let version: (u16, u16) = (parts.next().unwrap_or(0), parts.next().unwrap_or(...
identifier_body
build.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> extern crate gcc; extern crate pkg_config; use std::ascii::AsciiExt; use std::process::C...
} gcc_conf.file("src/gtk_glue.c"); // pass the GTK feature flags for cfg in &cfgs { gcc_conf.flag(&format!("-D{}", cfg.to_ascii_uppercase())); } // build library gcc_conf.compile("librgtk_glue.a"); }
{ let path: &Path = s[2..].as_ref(); gcc_conf.include(path); }
conditional_block
build.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> extern crate gcc; extern crate pkg_config; use std::ascii::AsciiExt; use std::process::C...
// build library gcc_conf.compile("librgtk_glue.a"); }
// pass the GTK feature flags for cfg in &cfgs { gcc_conf.flag(&format!("-D{}", cfg.to_ascii_uppercase())); }
random_line_split
mod.rs
mod raster; mod shader; mod samplers; use std::ops::Add; use std::ops::Mul; use std::f32; // A vector in 4-space. pub struct Vector([f32; 4]); // A 4x4 matrix. pub struct Matrix([f32; 16]); impl Vector { pub fn new(x: f32, y: f32, z: f32) -> Vector { Vector([x, y, z, 1.]) } pub fn zero() -> Vect...
pub fn put(&mut self, (x, y): (usize, usize), val: T) { self.data[x + (y * self.width)] = val; } pub fn get(&self, x: usize, y: usize) -> &T { &self.data[x + (y * self.width)] } } // Pixel blend modes. pub enum CompositeMode { SourceOver, } // A 32-bit ARGB colour. // Use premult...
data: data, } }
random_line_split
mod.rs
mod raster; mod shader; mod samplers; use std::ops::Add; use std::ops::Mul; use std::f32; // A vector in 4-space. pub struct Vector([f32; 4]); // A 4x4 matrix. pub struct Matrix([f32; 16]); impl Vector { pub fn new(x: f32, y: f32, z: f32) -> Vector { Vector([x, y, z, 1.]) } pub fn zero() -> Vect...
(&self) -> (u8, u8, u8, u8) { ((self.r * (u8::max_value() as f32)) as u8, (self.g * (u8::max_value() as f32)) as u8, (self.b * (u8::max_value() as f32)) as u8, (self.a * (u8::max_value() as f32)) as u8) } fn unpremultiply(&self) -> Color { Color { r: self....
to_rgba32
identifier_name
mod.rs
mod raster; mod shader; mod samplers; use std::ops::Add; use std::ops::Mul; use std::f32; // A vector in 4-space. pub struct Vector([f32; 4]); // A 4x4 matrix. pub struct Matrix([f32; 16]); impl Vector { pub fn new(x: f32, y: f32, z: f32) -> Vector { Vector([x, y, z, 1.]) } pub fn zero() -> Vect...
} impl Add for Color { type Output = Color; fn add(self, rhs: Color) -> Color { Color::new(self.r + rhs.r, self.g + rhs.g, self.b + rhs.b, self.a + rhs.a) } } // A standard render target with a ARGB color buffer and floating point depth // buffer. pub struct RenderTarget { width: usize, ...
{ Color::new(self.r * val, self.g * val, self.b * val, self.a * val) }
identifier_body
cargo_common_metadata.rs
//! lint on missing cargo common metadata use clippy_utils::{diagnostics::span_lint, is_lint_allowed}; use rustc_hir::hir_id::CRATE_HIR_ID; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::DUMMY_SP; declare_clippy_lint! { /// ### What...
if is_empty_vec(&package.categories) { missing_warning(cx, &package, "package.categories"); } } } } }
{ missing_warning(cx, &package, "package.keywords"); }
conditional_block
cargo_common_metadata.rs
//! lint on missing cargo common metadata use clippy_utils::{diagnostics::span_lint, is_lint_allowed}; use rustc_hir::hir_id::CRATE_HIR_ID; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::DUMMY_SP; declare_clippy_lint! { /// ### What...
{ ignore_publish: bool, } impl CargoCommonMetadata { pub fn new(ignore_publish: bool) -> Self { Self { ignore_publish } } } impl_lint_pass!(CargoCommonMetadata => [ CARGO_COMMON_METADATA ]); fn missing_warning(cx: &LateContext<'_>, package: &cargo_metadata::Package, field: &str) { let me...
CargoCommonMetadata
identifier_name
cargo_common_metadata.rs
//! lint on missing cargo common metadata use clippy_utils::{diagnostics::span_lint, is_lint_allowed}; use rustc_hir::hir_id::CRATE_HIR_ID; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::DUMMY_SP; declare_clippy_lint! { /// ### What...
missing_warning(cx, &package, "package.repository"); } if is_empty_str(&package.readme) { missing_warning(cx, &package, "package.readme"); } if is_empty_vec(&package.keywords) { missing_warning(...
{ if is_lint_allowed(cx, CARGO_COMMON_METADATA, CRATE_HIR_ID) { return; } let metadata = unwrap_cargo_metadata!(cx, CARGO_COMMON_METADATA, false); for package in metadata.packages { // only run the lint if publish is `None` (`publish = true` or skipped entirely)...
identifier_body
cargo_common_metadata.rs
//! lint on missing cargo common metadata use clippy_utils::{diagnostics::span_lint, is_lint_allowed}; use rustc_hir::hir_id::CRATE_HIR_ID; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::DUMMY_SP;
declare_clippy_lint! { /// ### What it does /// Checks to see if all common metadata is defined in /// `Cargo.toml`. See: https://rust-lang-nursery.github.io/api-guidelines/documentation.html#cargotoml-includes-all-common-metadata-c-metadata /// /// ### Why is this bad? /// It will be more diffi...
random_line_split