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
client.rs
//! Handle network connections for a varlink service #![allow(dead_code)] use std::net::TcpStream; #[cfg(unix)] use std::os::unix::io::{AsRawFd, IntoRawFd}; #[cfg(unix)] use std::os::unix::net::UnixStream; use std::process::Child; #[cfg(unix)] use libc::{close, dup2, getpid}; use tempfile::TempDir; #[cfg(windows)] u...
else { Err(context!(ErrorKind::InvalidAddress))? } } #[cfg(any(target_os = "linux", target_os = "android"))] fn get_abstract_unixstream(addr: &str) -> Result<UnixStream> { // FIXME: abstract unix domains sockets still not in std // FIXME: https://github.com/rust-lang/rust/issues/14194 use std:...
{ let mut addr = String::from(addr.split(';').next().unwrap()); if addr.starts_with('@') { addr = addr.replacen('@', "\0", 1); return get_abstract_unixstream(&addr) .map(|v| (Box::new(v) as Box<dyn Stream>, new_address)); } Ok(( Box::ne...
conditional_block
run_command.rs
extern crate std; extern crate hostname; extern crate glob; use std::str; use std::ffi::OsString; // Probably want OsStr in a few places use std::path::Path; use std::process::Command; use std::fs; use state::ShellState; impl ShellState { pub fn run_command(&self, command: &str, args: std::str::SplitWhitespace)
} if command == "ls" || command == "grep" { expanded_args.push(OsString::from("--color=auto")); } if Path::new(command).is_file() { match Command::new(Path::new(command)) .args(expanded_args) .current_dir(self.variables.get("PWD").u...
{ // Very crude glob support let mut expanded_args = Vec::new(); for arg in args { if !arg.contains('*') { expanded_args.push(OsString::from(arg)); continue; } let mut pattern = self.variables.get("PWD").unwrap().clone(); ...
identifier_body
run_command.rs
extern crate std; extern crate hostname; extern crate glob; use std::str; use std::ffi::OsString; // Probably want OsStr in a few places use std::path::Path; use std::process::Command; use std::fs; use state::ShellState; impl ShellState { pub fn
(&self, command: &str, args: std::str::SplitWhitespace) { // Very crude glob support let mut expanded_args = Vec::new(); for arg in args { if!arg.contains('*') { expanded_args.push(OsString::from(arg)); continue; } let mut pat...
run_command
identifier_name
run_command.rs
extern crate std; extern crate hostname; extern crate glob; use std::str; use std::ffi::OsString; // Probably want OsStr in a few places use std::path::Path; use std::process::Command; use std::fs; use state::ShellState; impl ShellState { pub fn run_command(&self, command: &str, args: std::str::SplitWhitespace) {...
.current_dir(self.variables.get("PWD").unwrap().clone()) .spawn() { Ok(mut child) => { child.wait().unwrap(); () } // This should be an unwrap_or_else Err(_) => println!("command failed to launch: {}", ...
if Path::new(command).is_file() { match Command::new(Path::new(command)) .args(expanded_args)
random_line_split
lights.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/. */ //! Module that implements lights for `PhilipsHueAdapter` //! //! This module implements AdapterManager-facing fun...
(&self) { // Nothing to do, yet } pub fn stop(&self) { // Nothing to do, yet } pub fn init_service(&mut self, manager: Arc<AdapterManager>, services: LightServiceMap) -> Result<(), Error> { let adapter_id = create_adapter_id(); let status = self.api.get_light_...
start
identifier_name
lights.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/. */ //! Module that implements lights for `PhilipsHueAdapter` //! //! This module implements AdapterManager-facing fun...
try!(manager.add_getter(Channel { tags: HashSet::new(), adapter: adapter_id.clone(), id: self.get_available_id.clone(), last_seen: None, service: self.service_id.clone(), mechanism: Getter { k...
{ info!("New Philips Hue Extended Color Light service for light {} on bridge {}", self.light_id, self.hub_id); let mut service = Service::empty(self.service_id.clone(), adapter_id.clone()); service.properties.insert(CUSTOM_PROPERTY_MANUFACTURER.to_owned(), ...
conditional_block
lights.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/. */ //! Module that implements lights for `PhilipsHueAdapter` //! //! This module implements AdapterManager-facing fun...
}
{ self.api.set_light_power(&self.light_id, on); }
identifier_body
lights.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/. */ //! Module that implements lights for `PhilipsHueAdapter` //! //! This module implements AdapterManager-facing fun...
}
}
random_line_split
complex.rs
use std::f64; use std::ops::Add; struct Complex { real:i32, imag:i32, } // operator overloading for Complex type impl Add for Complex { type Output = Complex; fn add(self,other:Complex) -> Complex {
} } impl Complex { fn new(x:i32,y:i32) -> Self { Complex {real:x,imag:y} } fn to_string(&self) -> String { if self.imag < 0 { format!("{}{}i",self.real,self.imag) } else { format!("{}+{}i",self.real,self.imag) } } fn times_ten(&mut self) { self.real *=10; self.imag *=10; } fn abs(&self) ...
Complex { real:self.real + other.real,imag:self.imag+other.imag }
random_line_split
complex.rs
use std::f64; use std::ops::Add; struct Complex { real:i32, imag:i32, } // operator overloading for Complex type impl Add for Complex { type Output = Complex; fn add(self,other:Complex) -> Complex { Complex { real:self.real + other.real,imag:self.imag+other.imag } } } impl Complex { fn new(x:i32,y:i32) -> ...
} fn times_ten(&mut self) { self.real *=10; self.imag *=10; } fn abs(&self) -> f64 { f64::floor(f64::sqrt((self.real*self.real) as f64 + (self.imag*self.imag) as f64)) } } fn main() { let comp1 = Complex::new(5,3); let comp2 = Complex::new(8,-8); let mut summation = comp1 + comp2; println!("{}",sum...
{ format!("{}+{}i",self.real,self.imag) }
conditional_block
complex.rs
use std::f64; use std::ops::Add; struct
{ real:i32, imag:i32, } // operator overloading for Complex type impl Add for Complex { type Output = Complex; fn add(self,other:Complex) -> Complex { Complex { real:self.real + other.real,imag:self.imag+other.imag } } } impl Complex { fn new(x:i32,y:i32) -> Self { Complex {real:x,imag:y} } fn to_strin...
Complex
identifier_name
complex.rs
use std::f64; use std::ops::Add; struct Complex { real:i32, imag:i32, } // operator overloading for Complex type impl Add for Complex { type Output = Complex; fn add(self,other:Complex) -> Complex { Complex { real:self.real + other.real,imag:self.imag+other.imag } } } impl Complex { fn new(x:i32,y:i32) -> ...
} fn main() { let comp1 = Complex::new(5,3); let comp2 = Complex::new(8,-8); let mut summation = comp1 + comp2; println!("{}",summation.to_string()); summation.times_ten(); //println!("10x -> {:?}",summation.to_string()); println!("Abs({}) => {}",summation.to_string(),summation.abs()); }
{ f64::floor(f64::sqrt((self.real*self.real) as f64 + (self.imag*self.imag) as f64)) }
identifier_body
riscv64gc_unknown_none_elf.rs
use crate::spec::{CodeModel, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel}; use crate::spec::{Target, TargetOptions}; pub fn target() -> Target
..Default::default() }, } }
{ Target { data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(), llvm_target: "riscv64".to_string(), pointer_width: 64, arch: "riscv64".to_string(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), linker: Some("r...
identifier_body
riscv64gc_unknown_none_elf.rs
use crate::spec::{CodeModel, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel}; use crate::spec::{Target, TargetOptions}; pub fn
() -> Target { Target { data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(), llvm_target: "riscv64".to_string(), pointer_width: 64, arch: "riscv64".to_string(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), li...
target
identifier_name
riscv64gc_unknown_none_elf.rs
use crate::spec::{CodeModel, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel}; use crate::spec::{Target, TargetOptions}; pub fn target() -> Target { Target { data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".to_string(), llvm_target: "riscv64".to_string(),
arch: "riscv64".to_string(), options: TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), linker: Some("rust-lld".to_string()), llvm_abiname: "lp64d".to_string(), cpu: "generic-rv64".to_string(), max_atomic_width: Some(64), ...
pointer_width: 64,
random_line_split
token.rs
// Lexical Tokens // // This file is part of AEx. // Copyright (C) 2017 Jeffrey Sharp // // AEx is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published // by the Free Software Foundation, either version 3 of the License, // or (at your option) any lat...
#[inline] pub fn add_bin(&mut self, c: char) { self.add_num(2, int_from_dg(c)) } #[inline] fn add_num(&mut self, base: u8, digit: u8) { self.number = &self.number * BigInt::from(base) + BigInt::from(digit); } #[inline] pub fn get_num(&mut self)...
{ self.add_num(8, int_from_dg(c)) }
identifier_body
token.rs
// Lexical Tokens // // This file is part of AEx. // Copyright (C) 2017 Jeffrey Sharp // // AEx is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published // by the Free Software Foundation, either version 3 of the License, // or (at your option) any lat...
(&mut self, c: char) { self.add_num(16, int_from_hex_lc(c)) } #[inline] pub fn add_oct(&mut self, c: char) { self.add_num(8, int_from_dg(c)) } #[inline] pub fn add_bin(&mut self, c: char) { self.add_num(2, int_from_dg(c)) } #[inline] fn add_num(&mut self, b...
add_hex_lc
identifier_name
token.rs
// Lexical Tokens // // This file is part of AEx. // Copyright (C) 2017 Jeffrey Sharp // // AEx is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published // by the Free Software Foundation, either version 3 of the License, // or (at your option) any lat...
// You should have received a copy of the GNU General Public License // along with AEx. If not, see <http://www.gnu.org/licenses/>. use std::cell::RefCell; use std::collections::HashMap; use num::{self, BigInt, ToPrimitive}; use aex::operator::{OperatorEntry, OperatorTable}; use aex::mem::StringInterner; use aex::m...
// WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See // the GNU General Public License for more details. //
random_line_split
htmlstyleelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::HTMLStyleElementBinding;
use dom::htmlelement::HTMLElement; use dom::node::{AbstractNode, Node, ScriptView}; pub struct HTMLStyleElement { htmlelement: HTMLElement, } impl HTMLStyleElement { pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLStyleElement { HTMLStyleElement { htmlelement: HTML...
use dom::bindings::utils::{DOMString, ErrorResult}; use dom::document::AbstractDocument; use dom::element::HTMLStyleElementTypeId;
random_line_split
htmlstyleelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::HTMLStyleElementBinding; use dom::bindings::utils::{DOMString, ErrorResult}; use dom::...
(&self) -> DOMString { None } pub fn SetMedia(&mut self, _media: &DOMString) -> ErrorResult { Ok(()) } pub fn Type(&self) -> DOMString { None } pub fn SetType(&mut self, _type: &DOMString) -> ErrorResult { Ok(()) } pub fn Scoped(&self) -> bool { ...
Media
identifier_name
htmlstyleelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::HTMLStyleElementBinding; use dom::bindings::utils::{DOMString, ErrorResult}; use dom::...
}
{ Ok(()) }
identifier_body
ref_binding_to_reference.rs
// edition:2018 // FIXME: run-rustfix waiting on multi-span suggestions #![warn(clippy::ref_binding_to_reference)] #![allow(clippy::needless_borrowed_reference)] fn f1(_: &str) {} macro_rules! m2 { ($e:expr) => { f1(*$e) }; } macro_rules! m3 { ($i:ident) => { Some(ref $i) }; } #[allow...
match Some(&x) { Some(ref x) => m2!(x), None => return, } // Err, reference to a &String let _ = |&ref x: &&String| { let _: &&String = x; }; } // Err, reference to a &String fn f2<'a>(&ref x: &&'a String) -> &'a String { let _: &&String = x; *x } trait T1 { //...
// Err, reference to a &String
random_line_split
ref_binding_to_reference.rs
// edition:2018 // FIXME: run-rustfix waiting on multi-span suggestions #![warn(clippy::ref_binding_to_reference)] #![allow(clippy::needless_borrowed_reference)] fn
(_: &str) {} macro_rules! m2 { ($e:expr) => { f1(*$e) }; } macro_rules! m3 { ($i:ident) => { Some(ref $i) }; } #[allow(dead_code)] fn main() { let x = String::new(); // Ok, the pattern is from a macro let _: &&String = match Some(&x) { m3!(x) => x, None => r...
f1
identifier_name
match-phi.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 ...
b => { x = false; } c => { x = false; } } }
{ x = true; foo(|_i| { } ) }
conditional_block
match-phi.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 = true; match a { a => { x = true; foo(|_i| { } ) } b => { x = false; } c => { x = false; } } }
main
identifier_name
scu_interrupt.rs
#[doc = r"Register block"] #[repr(C)] pub struct
{ #[doc = "0x00 - SCU Service Request Status"] pub srstat: crate::Reg<srstat::SRSTAT_SPEC>, #[doc = "0x04 - SCU Raw Service Request Status"] pub srraw: crate::Reg<srraw::SRRAW_SPEC>, #[doc = "0x08 - SCU Service Request Mask"] pub srmsk: crate::Reg<srmsk::SRMSK_SPEC>, #[doc = "0x0c - SCU Ser...
RegisterBlock
identifier_name
scu_interrupt.rs
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - SCU Service Request Status"] pub srstat: crate::Reg<srstat::SRSTAT_SPEC>, #[doc = "0x04 - SCU Raw Service Request Status"] pub srraw: crate::Reg<srraw::SRRAW_SPEC>, #[doc = "0x08 - SCU Service Request Mask"] pub srm...
#[doc = "SCU Service Request Mask"] pub mod srmsk; #[doc = "SRCLR register accessor: an alias for `Reg<SRCLR_SPEC>`"] pub type SRCLR = crate::Reg<srclr::SRCLR_SPEC>; #[doc = "SCU Service Request Clear"] pub mod srclr; #[doc = "SRSET register accessor: an alias for `Reg<SRSET_SPEC>`"] pub type SRSET = crate::Reg<srset::...
#[doc = "SCU Raw Service Request Status"] pub mod srraw; #[doc = "SRMSK register accessor: an alias for `Reg<SRMSK_SPEC>`"] pub type SRMSK = crate::Reg<srmsk::SRMSK_SPEC>;
random_line_split
lib.rs
//! aobench: Ambient Occlusion Renderer benchmark. //! //! Based on [aobench](https://code.google.com/archive/p/aobench/) by Syoyo //! Fujita. #![deny(warnings, rust_2018_idioms)] #![allow(non_snake_case, non_camel_case_types)] #![cfg_attr( feature = "cargo-clippy", allow( clippy::many_single_char_names...
pub mod tiled; pub mod tiled_parallel; pub mod vector; pub mod vector_parallel; pub use self::image::Image; pub use self::scene::Scene;
random_line_split
main.rs
use std::io; // io::stdin().read_line(&mut <String>) use std::f64; // f64::NAN fn get_input() -> String { let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(string) => string, Err(err) => panic!("Error: {}", err), }; input } fn main() { let pairs: isize =...
else { div /= num; } } let div = div.round() as isize; data.push(div); } println!(""); for ans in data { print!("{} ", ans); } println!(""); }
for num in pairs { if div.is_nan() { div = num; }
random_line_split
main.rs
use std::io; // io::stdin().read_line(&mut <String>) use std::f64; // f64::NAN fn get_input() -> String { let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(string) => string, Err(err) => panic!("Error: {}", err), }; input } fn main()
else { div /= num; } } let div = div.round() as isize; data.push(div); } println!(""); for ans in data { print!("{} ", ans); } println!(""); }
{ let pairs: isize = get_input() .trim() .parse::<isize>().expect("Error: can't parse input"); let mut data: Vec<isize> = Vec::new(); for _ in 0..pairs { let pairs: Vec<f64> = get_input() .trim() .split_whitespace() .map(|s| s.parse::<f64>().expe...
identifier_body
main.rs
use std::io; // io::stdin().read_line(&mut <String>) use std::f64; // f64::NAN fn
() -> String { let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(string) => string, Err(err) => panic!("Error: {}", err), }; input } fn main() { let pairs: isize = get_input() .trim() .parse::<isize>().expect("Error: can't parse input"); ...
get_input
identifier_name
procedural_mbe_matching.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 ...
{ reg.register_macro("matches", expand_mbe_matches); }
identifier_body
procedural_mbe_matching.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 ...
(reg: &mut Registry) { reg.register_macro("matches", expand_mbe_matches); }
plugin_registrar
identifier_name
procedural_mbe_matching.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 expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree]) -> Box<MacResult +'static> { let mbe_matcher = quote_tokens!(cx, $$matched:expr, $$($$pat:pat)|+); let mbe_matcher = quoted::parse(mbe_matcher.into_iter().collect(), true, ...
use syntax_pos::{Span, edition::Edition}; use rustc_plugin::Registry;
random_line_split
issue-11612.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 ...
(&self) { } } struct B<'a, T:'a> { f: &'a T } impl<'a, T> A for B<'a, T> {} fn foo(_: &A) {} fn bar<G>(b: &B<G>) { foo(b); // Coercion should work foo(b as &A); // Explicit cast should work as well } fn main() {}
dummy
identifier_name
issue-11612.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{}
identifier_body
issue-11612.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 ...
trait A { fn dummy(&self) { } } struct B<'a, T:'a> { f: &'a T } impl<'a, T> A for B<'a, T> {} fn foo(_: &A) {} fn bar<G>(b: &B<G>) { foo(b); // Coercion should work foo(b as &A); // Explicit cast should work as well } fn main() {}
// pretty-expanded FIXME #23616
random_line_split
arm64_old.rs
// Copyright 2015 Ted Mielczarek. See the COPYRIGHT // file at the top-level directory of this distribution. // NOTE: arm64_old.rs and arm64.rs should be identical except for the names of // their context types. use crate::process_state::{FrameTrust, StackFrame}; use crate::stackwalker::unwind::Unwind; use crate::sta...
(instruction: Pointer) -> bool { // Reject instructions in the first page or above the user-space threshold. !(0x1000..=0x000fffffffffffff).contains(&instruction) } /* // ARM64 is currently hyper-permissive, so we don't use this, // but here it is in case we change our minds! fn stack_seems_valid( caller_sp...
is_non_canonical
identifier_name
arm64_old.rs
// Copyright 2015 Ted Mielczarek. See the COPYRIGHT // file at the top-level directory of this distribution. // NOTE: arm64_old.rs and arm64.rs should be identical except for the names of // their context types. use crate::process_state::{FrameTrust, StackFrame}; use crate::stackwalker::unwind::Unwind; use crate::sta...
// if the instruction is within the first ~page of memory, it's basically // null, and we can assume unwinding is complete. if frame.context.get_instruction_pointer() < 4096 { trace!("unwind: instruction pointer was nullish, assuming unwind complete"); return None; ...
{ let stack = stack_memory.as_ref()?; // .await doesn't like closures, so don't use Option chaining let mut frame = None; if frame.is_none() { frame = get_caller_by_cfi(self, callee, grand_callee, stack, modules, syms).await; } if frame.is_none() { ...
identifier_body
arm64_old.rs
// Copyright 2015 Ted Mielczarek. See the COPYRIGHT // file at the top-level directory of this distribution. // NOTE: arm64_old.rs and arm64.rs should be identical except for the names of // their context types. use crate::process_state::{FrameTrust, StackFrame}; use crate::stackwalker::unwind::Unwind; use crate::sta...
ctx: &ArmContext, callee: &StackFrame, stack_memory: &MinidumpMemory<'_>, modules: &MinidumpModuleList, symbol_provider: &P, ) -> Option<StackFrame> where P: SymbolProvider + Sync, { trace!("unwind: trying scan"); // Stack scanning is just walking from the end of the frame until we encou...
ptr } async fn get_caller_by_scan<P>(
random_line_split
arm64_old.rs
// Copyright 2015 Ted Mielczarek. See the COPYRIGHT // file at the top-level directory of this distribution. // NOTE: arm64_old.rs and arm64.rs should be identical except for the names of // their context types. use crate::process_state::{FrameTrust, StackFrame}; use crate::stackwalker::unwind::Unwind; use crate::sta...
super::instruction_seems_valid_by_symbols(instruction as u64, modules, symbol_provider).await } fn is_non_canonical(instruction: Pointer) -> bool { // Reject instructions in the first page or above the user-space threshold. !(0x1000..=0x000fffffffffffff).contains(&instruction) } /* // ARM64 is currently ...
{ return false; }
conditional_block
scanner.rs
// The MIT License (MIT) // // Copyright (c) 2017 Doublify Technologies // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // t...
() { let raw_query = "subject:{'fdhadzh' 'goodmind'}"; let expected = vec![Token::new(Kind::Identifier, "subject"), Token::new(Kind::Colon, ":"), Token::new(Kind::Curly, "{"), Token::new(Kind::Identifier, "'fdhadzh'"), Token::n...
scan_raw_query_test_1
identifier_name
scanner.rs
// The MIT License (MIT) // // Copyright (c) 2017 Doublify Technologies // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // t...
assert_eq!(expected, wanted); }
let wanted = scan(raw_query);
random_line_split
scanner.rs
// The MIT License (MIT) // // Copyright (c) 2017 Doublify Technologies // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // t...
#[test] fn scan_raw_query_test_2() { let raw_query = "languages:(\"rust\" \"python\" \"typescript\") is:stable"; let expected = vec![Token::new(Kind::Identifier, "languages"), Token::new(Kind::Colon, ":"), Token::new(Kind::Parentheses, "("), Token...
{ let raw_query = "subject:{'fdhadzh' 'goodmind'}"; let expected = vec![Token::new(Kind::Identifier, "subject"), Token::new(Kind::Colon, ":"), Token::new(Kind::Curly, "{"), Token::new(Kind::Identifier, "'fdhadzh'"), Token::new(...
identifier_body
explorer_factory.rs
// The MIT License (MIT) // // Copyright (c) 2015 dinowernli // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy...
fn create_monte_carlo_explorer<'a>( &self, predictor: &'a mut Predictor) -> Box<Explorer + 'a> { Box::new(MonteCarloExplorer::new(predictor)) } fn create_random_explorer(&self) -> Box<Explorer> { Box::new(RandomExplorer::new(Box::new(RandomImpl::create(235669)))) } }
random_line_split
explorer_factory.rs
// The MIT License (MIT) // // Copyright (c) 2015 dinowernli // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy...
() -> ExplorerFactoryImpl { ExplorerFactoryImpl } } impl ExplorerFactory for ExplorerFactoryImpl { fn create_monte_carlo_explorer<'a>( &self, predictor: &'a mut Predictor) -> Box<Explorer + 'a> { Box::new(MonteCarloExplorer::new(predictor)) } fn create_random_explorer(&self) -> Box<Explorer> { Box...
new
identifier_name
import_tests.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::unit_tests::testutils::{ compile_module_string_with_stdlib, compile_script_string_with_stdlib, }; #[test] fn compile_script_with_imports() { let code = String::from( " import 0x1.DiemCoin; ma...
() { let code = String::from( " module Foobar { import 0x1.DiemCoin; struct FooCoin { value: u64 } public value(this: &Self.FooCoin): u64 { let value_ref: &u64; value_ref = &move(this).value; return *move(value_ref...
compile_module_with_imports
identifier_name
import_tests.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::unit_tests::testutils::{ compile_module_string_with_stdlib, compile_script_string_with_stdlib, }; #[test] fn compile_script_with_imports() { let code = String::from( " import 0x1.DiemCoin; ma...
" module Foobar { import 0x1.DiemCoin; struct FooCoin { value: u64 } public value(this: &Self.FooCoin): u64 { let value_ref: &u64; value_ref = &move(this).value; return *move(value_ref); } publ...
random_line_split
import_tests.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::unit_tests::testutils::{ compile_module_string_with_stdlib, compile_script_string_with_stdlib, }; #[test] fn compile_script_with_imports()
#[test] fn compile_module_with_imports() { let code = String::from( " module Foobar { import 0x1.DiemCoin; struct FooCoin { value: u64 } public value(this: &Self.FooCoin): u64 { let value_ref: &u64; value_ref = &move(this).value...
{ let code = String::from( " import 0x1.DiemCoin; main() { let x: u64; let y: u64; x = 2; y = copy(x) + copy(x); return; } ", ); let compiled_script_res = compile_script_string_with_stdlib(&code); let _c...
identifier_body
filters.rs
#[allow(unused_imports)] use serde::json; use serde::json::value; use serde::json::Value; use chrono::offset::utc::UTC; #[allow(dead_code)] fn int_to_level(level: u64) -> String { match level { 10 => "trace".to_string(), 20 => "debug".to_string(), 30 => "info".to_string(), 40 => "warn".to_string(), ...
#[test] fn it_prepares_index_name() { // let src = r#"{"name":"stakhanov","hostname":"Quark.local","pid":65470,"level":30,"msg":"pushing http://fr.wikipedia.org/wiki/Giant_Sand","time":"2015-05-21T10:11:02.132Z","v":0}"#; let src = r#"{"time": "2015-05-21T10:11:02.132Z"}"#; let decode = json::from_str::<Value>(...
{ // let src = r#"{"name":"stakhanov","hostname":"Quark.local","pid":65470,"level":30,"msg":"pushing http://fr.wikipedia.org/wiki/Giant_Sand","time":"2015-05-21T10:11:02.132Z","v":0}"#; let src = r#"{"level":30, "msg":"this is a test.", "time": "12"}"#; let mut decode = json::from_str::<Value>(src).unwrap(); le...
identifier_body
filters.rs
#[allow(unused_imports)] use serde::json; use serde::json::value; use serde::json::Value; use chrono::offset::utc::UTC; #[allow(dead_code)] fn int_to_level(level: u64) -> String { match level { 10 => "trace".to_string(), 20 => "debug".to_string(), 30 => "info".to_string(), 40 => "warn".to_string(), ...
// 01234567890123456789012 let mut timestamp = tm.format(format_prefix.as_ref()).to_string(); timestamp.truncate(23); let timestamp_suffix = tm.format(format_suffix.as_ref()).to_string(); timestamp.push_str(&timestamp_suffix); input.insert("@timestamp".to_string(), value::to_value(&timestamp))...
random_line_split
filters.rs
#[allow(unused_imports)] use serde::json; use serde::json::value; use serde::json::Value; use chrono::offset::utc::UTC; #[allow(dead_code)] fn int_to_level(level: u64) -> String { match level { 10 => "trace".to_string(), 20 => "debug".to_string(), 30 => "info".to_string(), 40 => "warn".to_string(), ...
(full_timestamp: &str) -> String { // compatible with "2015-05-21T10:11:02.132Z" let mut input = full_timestamp.to_string(); input.truncate(10); input = input.replace("-", "."); format!("logstash-{}", input) } #[test] fn it_transform_ok() { // let src = r#"{"name":"stakhanov","hostname":"Quark.local","pid"...
time_to_index_name
identifier_name
root.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/. */ /// Liberally derived from the [Firefox JS implementation] /// (http://mxr.mozilla.org/mozilla-central/source/tool...
{ from: String, selected: u32, tabs: Vec<BrowsingContextActorMsg>, } #[derive(Serialize)] pub struct RootActorMsg { from: String, applicationType: String, traits: ActorTraits, } #[derive(Serialize)] pub struct ProtocolDescriptionReply { from: String, types: Types, } #[derive(Serializ...
ListTabsReply
identifier_name
root.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/. */ /// Liberally derived from the [Firefox JS implementation] /// (http://mxr.mozilla.org/mozilla-central/source/tool...
, _ => ActorMessageStatus::Ignored, }) } } impl RootActor { pub fn encodable(&self) -> RootActorMsg { RootActorMsg { from: "root".to_owned(), applicationType: "browser".to_owned(), traits: ActorTraits { sources: true, ...
{ let msg = ProtocolDescriptionReply { from: self.name(), types: Types { performance: PerformanceActor::description(), device: DeviceActor::description(), }, }; str...
conditional_block
root.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/. */ /// Liberally derived from the [Firefox JS implementation] /// (http://mxr.mozilla.org/mozilla-central/source/tool...
struct ActorTraits { sources: bool, highlightable: bool, customHighlighters: bool, networkMonitor: bool, } #[derive(Serialize)] struct ListAddonsReply { from: String, addons: Vec<AddonMsg>, } #[derive(Serialize)] enum AddonMsg {} #[derive(Serialize)] struct GetRootReply { from: String, ...
#[derive(Serialize)]
random_line_split
regions-assoc-type-region-bound-in-trait-not-met.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. //
// 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. // Test that the compiler checks that arbitrary region bounds declared // in the trait m...
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
regions-assoc-type-region-bound-in-trait-not-met.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 ...
} impl<'a> Foo<'a> for &'a i16 { // OK. type Value = &'a i32; } impl<'a> Foo<'static> for &'a i32 { //~^ ERROR cannot infer type Value = &'a i32; } impl<'a,'b> Foo<'b> for &'a i64 { //~^ ERROR cannot infer type Value = &'a i32; } fn main() { }
{ }
identifier_body
regions-assoc-type-region-bound-in-trait-not-met.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 ...
() { }
main
identifier_name
out-pointer-aliasing.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let mut f = Foo { f1: 8, _f2: 9, }; f = foo(&mut f); assert_eq!(f.f1, 8); }
{ let ret = *f; f.f1 = 0; ret }
identifier_body
out-pointer-aliasing.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(f: &mut Foo) -> Foo { let ret = *f; f.f1 = 0; ret } pub fn main() { let mut f = Foo { f1: 8, _f2: 9, }; f = foo(&mut f); assert_eq!(f.f1, 8); }
foo
identifier_name
out-pointer-aliasing.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 ...
f1: int, _f2: int, } impl Copy for Foo {} #[inline(never)] pub fn foo(f: &mut Foo) -> Foo { let ret = *f; f.f1 = 0; ret } pub fn main() { let mut f = Foo { f1: 8, _f2: 9, }; f = foo(&mut f); assert_eq!(f.f1, 8); }
pub struct Foo {
random_line_split
font.rs
use app_units::Au; use euclid::{Point2D, Rect, Size2D}; use font_context::{FontContext, FontSource}; use font_template::FontTemplateDescriptor; use ordered_float::NotNan; use platform::font::{FontHandle, FontTable}; use platform::font_context::FontContextHandle; pub use platform::font_list::fallback_font_families; use...
{ /// A specific name such as `"Arial"` Specific(Atom), /// A generic name such as `sans-serif` Generic(Atom), } impl FontFamilyName { pub fn name(&self) -> &str { match *self { FontFamilyName::Specific(ref name) => name, FontFamilyName::Generic(ref name) => name, ...
FontFamilyName
identifier_name
font.rs
use app_units::Au; use euclid::{Point2D, Rect, Size2D}; use font_context::{FontContext, FontSource}; use font_template::FontTemplateDescriptor; use ordered_float::NotNan; use platform::font::{FontHandle, FontTable}; use platform::font_context::FontContextHandle; pub use platform::font_list::fallback_font_families; use...
} pub struct RunMetrics { // may be negative due to negative width (i.e., kerning of '.' in 'P.T.') pub advance_width: Au, pub ascent: Au, // nonzero pub descent: Au, // nonzero // this bounding box is relative to the left origin baseline. // so, bounding_box.position.y = -ascent pub boun...
{ if !self.loaded { self.font = font_context.font(&self.font_descriptor, &self.family_descriptor); self.loaded = true; } self.font.clone() }
identifier_body
font.rs
use app_units::Au; use euclid::{Point2D, Rect, Size2D}; use font_context::{FontContext, FontSource}; use font_template::FontTemplateDescriptor; use ordered_float::NotNan; use platform::font::{FontHandle, FontTable}; use platform::font_context::FontContextHandle; pub use platform::font_list::fallback_font_families; us...
} } } impl<'a> From<&'a SingleFontFamily> for FontFamilyName { fn from(other: &'a SingleFontFamily) -> FontFamilyName { match *other { SingleFontFamily::FamilyName(ref family_name) => { FontFamilyName::Specific(family_name.name.clone()) }, Si...
FontFamilyName::Generic(ref name) => name,
random_line_split
font.rs
use app_units::Au; use euclid::{Point2D, Rect, Size2D}; use font_context::{FontContext, FontSource}; use font_template::FontTemplateDescriptor; use ordered_float::NotNan; use platform::font::{FontHandle, FontTable}; use platform::font_context::FontContextHandle; pub use platform::font_list::fallback_font_families; use...
} let font = self.find_fallback(&mut font_context, Some(codepoint), has_glyph); if font.is_some() { self.last_matching_fallback = font.clone(); return font; } self.first(&mut font_context) } /// Find the first available font in the group, or th...
{ return self.last_matching_fallback.clone(); }
conditional_block
utils.rs
use num::bigint::{ToBigUint, BigUint}; use num::traits::{One, ToPrimitive}; use std::num::ParseIntError; use std::mem; pub trait Max { fn max(width: u32) -> Self; } impl Max for BigUint { fn max(width: u32) -> BigUint { (BigUint::one() << width as usize) - BigUint::one() } } pub trait ParseNum { ...
#[cfg(test)] mod test_util { use num::bigint::{BigUint, ToBigUint}; use num::traits::{One, Zero}; use utils::AsRaw; use utils::Hamming; use utils::LastCache; #[test] fn test_hamming() { let full_128_bu = { let mut res = BigUint::zero(); for i in 0..128 { ...
random_line_split
utils.rs
use num::bigint::{ToBigUint, BigUint}; use num::traits::{One, ToPrimitive}; use std::num::ParseIntError; use std::mem; pub trait Max { fn max(width: u32) -> Self; } impl Max for BigUint { fn max(width: u32) -> BigUint { (BigUint::one() << width as usize) - BigUint::one() } } pub trait ParseNum { ...
else { assert_eq!(*item, 1); } i += 1; } } #[test] fn test_as_raw_f32() { use std::f32::INFINITY; assert_eq!(2.8411367E-29f32.as_raw(), 0x10101010); assert_eq!((-4.99999998E11f32).as_raw(), 0xd2e8d4a5); assert_eq!(100.0f32.as_...
{ assert_eq!(*item, 2); }
conditional_block
utils.rs
use num::bigint::{ToBigUint, BigUint}; use num::traits::{One, ToPrimitive}; use std::num::ParseIntError; use std::mem; pub trait Max { fn max(width: u32) -> Self; } impl Max for BigUint { fn max(width: u32) -> BigUint { (BigUint::one() << width as usize) - BigUint::one() } } pub trait ParseNum { ...
(&self) -> u32 { unsafe { mem::transmute(*self) } } } impl AsRaw<u64> for f64 { fn as_raw(&self) -> u64 { unsafe { mem::transmute(*self) } } } use std::collections::VecDeque; use std::collections::vec_deque; // Objects pub struct LastCache<T> { stack: VecDeque<T>, max: usize } imp...
as_raw
identifier_name
panicking.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::any::Any; use std::boxed::FnBox; use std::cell::RefCell; use std::panic::{PanicInfo, take_hook, set_hook}...
}); }; set_hook(Box::new(new_hook)); }); }
{ hook(&info); }
conditional_block
panicking.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::any::Any; use std::boxed::FnBox; use std::cell::RefCell; use std::panic::{PanicInfo, take_hook, set_hook}...
(local: Box<FnBox(&Any)>) { LOCAL_INFO.with(|i| *i.borrow_mut() = Some(PanicHandlerLocal { fail: local })); } /// Initiates the custom panic hook /// Should be called in main() after arguments have been parsed pub fn initiate_panic_hook() { // Set the panic handler only once. It is global. HOOK_SET.call_on...
set_thread_local_hook
identifier_name
panicking.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::any::Any; use std::boxed::FnBox; use std::cell::RefCell; use std::panic::{PanicInfo, take_hook, set_hook}...
// The original backtrace-printing hook. We still want to call this let hook = take_hook(); let new_hook = move |info: &PanicInfo| { let payload = info.payload(); let name = thread::current().name().unwrap_or("<unknown thread>").to_string(); // Notify error h...
pub fn initiate_panic_hook() { // Set the panic handler only once. It is global. HOOK_SET.call_once(|| {
random_line_split
day09.rs
extern crate permutohedron; extern crate pcre; use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::collections::{HashMap, HashSet}; use std::cmp::{min, max}; use permutohedron::Heap; use pcre::Pcre; fn
() { let f = File::open("day9.in").unwrap(); let file = BufReader::new(&f); let mut distances : HashMap<(String,String), i32> = HashMap::new(); let mut cities: HashSet<String> = HashSet::new(); let mut re = Pcre::compile(r"(\w+) to (\w+) = (\d+)").unwrap(); for line in file.lines() { le...
main
identifier_name
day09.rs
extern crate permutohedron; extern crate pcre; use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::collections::{HashMap, HashSet}; use std::cmp::{min, max}; use permutohedron::Heap; use pcre::Pcre; fn main() { let f = File::open("day9.in").unwrap(); let file = BufReader::new(&f); l...
let mut cities_vec: Vec<String> = cities.into_iter().collect(); for p in Heap::new(&mut cities_vec) { let mut dist = 0; for (a,b) in p.iter().zip(p[1..p.len()].iter()) { dist += distances[&(a.to_string(),b.to_string())]; } min_dist = min(min_dist, dist); max...
let mut min_dist = 1000000; let mut max_dist = 0;
random_line_split
day09.rs
extern crate permutohedron; extern crate pcre; use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::collections::{HashMap, HashSet}; use std::cmp::{min, max}; use permutohedron::Heap; use pcre::Pcre; fn main()
} let mut min_dist = 1000000; let mut max_dist = 0; let mut cities_vec: Vec<String> = cities.into_iter().collect(); for p in Heap::new(&mut cities_vec) { let mut dist = 0; for (a,b) in p.iter().zip(p[1..p.len()].iter()) { dist += distances[&(a.to_string(),b.to_string()...
{ let f = File::open("day9.in").unwrap(); let file = BufReader::new(&f); let mut distances : HashMap<(String,String), i32> = HashMap::new(); let mut cities: HashSet<String> = HashSet::new(); let mut re = Pcre::compile(r"(\w+) to (\w+) = (\d+)").unwrap(); for line in file.lines() { let l...
identifier_body
mod.rs
resolve_ivar) { Ok(resulting_type) if!type_is_ty_var(resulting_type) => resulting_type, _ => { inference_context.tcx.sess.span_fatal(span, "the type of this value must be known in order \ ...
fn get_self_type_for_implementation(&self, impl_did: DefId) -> Polytype { self.crate_context.tcx.tcache.borrow().get_copy(&impl_did) } // Converts an implementation in the AST to a vector of items. fn create_impl_from_item(&self, item: &Item) -> Vec<Imp...
{ debug!("add_trait_impl: base_def_id={} impl_def_id={}", base_def_id, impl_def_id); ty::record_trait_implementation(self.crate_context.tcx, base_def_id, impl_def_id); }
identifier_body
mod.rs
resolve_ivar) { Ok(resulting_type) if!type_is_ty_var(resulting_type) => resulting_type, _ => { inference_context.tcx.sess.span_fatal(span, "the type of this value must be known in order \ ...
self.instantiate_default_methods(local_def(item.id), &*ty_trait_ref, &mut items); } items } _ => { self.crate_context.tc...
{ let mut items: Vec<ImplOrTraitItemId> = ast_items.iter() .map(|ast_item| { match *ast_item { ast::MethodImplItem(ref ast_method) => { MethodTraitItem...
conditional_block
mod.rs
debug!("(getting base type) no base type; found {}", get(original_type).sty); None } ty_trait(..) => fail!("should have been caught") } } // Returns the def ID of the base type, if there is one. fn get_base_type_def_id(inference_context: &InferCtxt, ...
make_substs_for_receiver_types
identifier_name
mod.rs
resolve_ivar) { Ok(resulting_type) if!type_is_ty_var(resulting_type) => resulting_type, _ => { inference_context.tcx.sess.span_fatal(span, "the type of this value must be known in order \ ...
fn add_external_impl(&self, impls_seen: &mut HashSet<DefId>, impl_def_id: DefId) { let tcx = self.crate_context.tcx; let impl_items = csearch::get_impl_items(&tcx.sess.cstore, impl_def_id); /...
random_line_split
tee.rs
#![crate_name = "uu_tee"] /* * This file is part of the uutils coreutils package. * * (c) Aleksander Bielawski <pabzdzdzwiagief@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern...
(message: &str) -> Error { eprintln!("{}: {}", NAME, message); Error::new(ErrorKind::Other, format!("{}: {}", NAME, message)) }
warn
identifier_name
tee.rs
#![crate_name = "uu_tee"] /* * This file is part of the uutils coreutils package. * * (c) Aleksander Bielawski <pabzdzdzwiagief@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern...
} struct NamedWriter { inner: Box<Write>, path: PathBuf } impl Write for NamedWriter { fn write(&mut self, buf: &[u8]) -> Result<usize> { match self.inner.write(buf) { Err(f) => { self.inner = Box::new(sink()) as Box<Write>; warn(format!("{}: {}", self....
{ for writer in &mut self.writers { try!(writer.flush()); } Ok(()) }
identifier_body
tee.rs
#![crate_name = "uu_tee"] /* * This file is part of the uutils coreutils package. * * (c) Aleksander Bielawski <pabzdzdzwiagief@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern...
} } fn warn(message: &str) -> Error { eprintln!("{}: {}", NAME, message); Error::new(ErrorKind::Other, format!("{}: {}", NAME, message)) }
okay => okay }
random_line_split
ptr.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...
/// /// # Examples /// /// ``` /// use std::ptr; /// /// let p: *mut i32 = ptr::null_mut(); /// assert!(p.is_null()); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn null_mut<T>() -> *mut T { 0 as *mut T } /// Swaps the values at two mutable locations of the same type, without /// deinitialising...
/// Creates a null mutable raw pointer.
random_line_split
ptr.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...
/// Returns `None` if the pointer is null, or else returns a reference to /// the value wrapped in `Some`. /// /// # Safety /// /// While this method and its mutable counterpart are useful for /// null-safety, it is important to note that this is still an unsafe /// operation because t...
{ self == 0 as *mut T }
identifier_body
ptr.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...
else if self == other { Equal } else { Greater } } } #[stable(feature = "rust1", since = "1.0.0")] impl<T:?Sized> PartialOrd for *const T { #[inline] fn partial_cmp(&self, other: &*const T) -> Option<Ordering> { Some(self.cmp(other)) } #[inline] ...
{ Less }
conditional_block
ptr.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(&self, other: &*const T) -> bool { *self >= *other } } #[stable(feature = "rust1", since = "1.0.0")] impl<T:?Sized> Ord for *mut T { #[inline] fn cmp(&self, other: &*mut T) -> Ordering { if self < other { Less } else if self == other { Equal } else { ...
ge
identifier_name
lib.rs
#![crate_name = "nickel"] #![comment = "A expressjs inspired web framework for Rust"] #![license = "MIT"] #![crate_type = "rlib"] #![feature(macro_rules, phase, slicing_syntax)] //!Nickel is supposed to be a simple and lightweight foundation for web applications written in Rust. Its API is inspired by the popular expr...
//!* Easy handlers: A handler is just a function that takes a `Request` and `ResponseWriter` //!* Variables in routes. Just write `my/route/:someid` //!* Easy parameter access: `request.params.get(&"someid")` //!* simple wildcard routes: `/some/*/route` //!* double wildcard routes: `/a/**/route` //!* middleware extern...
//!Some of the features are: //!
random_line_split
env.rs
// Copyright 2017 Jeremy Wall <jeremy@marzhillstudios.com> // // 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 ...
(&self) -> String { String::from("env") } fn description(&self) -> String { "Convert ucg Vals into environment variables.".to_string() } #[allow(unused_must_use)] fn help(&self) -> String { include_str!("env_help.txt").to_string() } }
file_ext
identifier_name
env.rs
// Copyright 2017 Jeremy Wall <jeremy@marzhillstudios.com> // // 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 ...
if let &Val::Empty = val.as_ref() { eprintln!("Skipping empty variable: {}", name); return Ok(()); } write!(w, "{}=", name)?; self.write(&val, w)?; } Ok(()) } fn convert_list(&self, _items: &Vec<Rc<Val>>, _w: &mut ...
{ eprintln!("Skipping embedded tuple..."); return Ok(()); }
conditional_block
env.rs
// Copyright 2017 Jeremy Wall <jeremy@marzhillstudios.com> // // 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
// Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the Lic...
// // http://www.apache.org/licenses/LICENSE-2.0 //
random_line_split
env.rs
// Copyright 2017 Jeremy Wall <jeremy@marzhillstudios.com> // // 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 ...
fn convert_list(&self, _items: &Vec<Rc<Val>>, _w: &mut dyn IOWrite) -> ConvertResult { eprintln!("Skipping List..."); Ok(()) } fn write(&self, v: &Val, w: &mut dyn IOWrite) -> ConvertResult { match v { &Val::Empty => { // Empty is a noop. ...
{ for &(ref name, ref val) in flds.iter() { if val.is_tuple() { eprintln!("Skipping embedded tuple..."); return Ok(()); } if let &Val::Empty = val.as_ref() { eprintln!("Skipping empty variable: {}", name); return...
identifier_body
progpoint.rs
//! Program points. use entity::EntityRef; use ir::{Ebb, Inst, ValueDef}; use std::fmt; use std::u32; use std::cmp; /// A `ProgramPoint` represents a position in a function where the live range of an SSA value can /// begin or end. It can be either: /// /// 1. An instruction or /// 2. An EBB header. /// /// This corr...
(pp: ProgramPoint) -> ExpandedProgramPoint { if pp.0 & 1 == 0 { ExpandedProgramPoint::Inst(Inst::new((pp.0 / 2) as usize)) } else { ExpandedProgramPoint::Ebb(Ebb::new((pp.0 / 2) as usize)) } } } impl fmt::Display for ExpandedProgramPoint { fn fmt(&self, f: &mut f...
from
identifier_name
progpoint.rs
//! Program points. use entity::EntityRef; use ir::{Ebb, Inst, ValueDef}; use std::fmt; use std::u32; use std::cmp; /// A `ProgramPoint` represents a position in a function where the live range of an SSA value can /// begin or end. It can be either: /// /// 1. An instruction or /// 2. An EBB header. /// /// This corr...
/// This is declared as a generic such that it can be called with `Inst` and `Ebb` arguments /// directly. Depending on the implementation, there is a good chance performance will be /// improved for those cases where the type of either argument is known statically. fn cmp<A, B>(&self, a: A, b: B) -> cm...
/// /// Return `Less` if `a` appears in the program before `b`. ///
random_line_split
progpoint.rs
//! Program points. use entity::EntityRef; use ir::{Ebb, Inst, ValueDef}; use std::fmt; use std::u32; use std::cmp; /// A `ProgramPoint` represents a position in a function where the live range of an SSA value can /// begin or end. It can be either: /// /// 1. An instruction or /// 2. An EBB header. /// /// This corr...
} impl fmt::Debug for ProgramPoint { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ProgramPoint({})", self) } } /// Context for ordering program points. /// /// `ProgramPoint` objects don't carry enough information to be ordered independently, they need a /// context providing the...
{ write!(f, "ExpandedProgramPoint({})", self) }
identifier_body
panic.rs
use pi::uart::MiniUart; use core::fmt::{Write, Arguments}; #[lang = "eh_personality"] pub extern "C" fn eh_personality() {} #[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt(msg: Arguments, file: &'static str, line: u32, col: u32) ->! { let mut uart = MiniUart::new(); let _ = uart.write_str("\n\n---...
(dest: *mut u8, src: *const u8, n: usize) -> *mut u8 { if src < dest as *const u8 { // copy from end let mut i = n; while i!= 0 { i -= 1; *dest.offset(i as isize) = *src.offset(i as isize); } } else { // copy from beginning let mut i = 0; while i <...
memmove
identifier_name
panic.rs
use pi::uart::MiniUart; use core::fmt::{Write, Arguments}; #[lang = "eh_personality"] pub extern "C" fn eh_personality() {} #[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt(msg: Arguments, file: &'static str, line: u32, col: u32) ->!
#[no_mangle] #[lang = "oom"] pub unsafe extern "C" fn rust_oom() ->! { panic!("OOM") } #[no_mangle] pub unsafe extern fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8 { let mut i = 0; while i < n { *dest.offset(i as isize) = *src.offset(i as isize); i += 1; } return d...
{ let mut uart = MiniUart::new(); let _ = uart.write_str("\n\n---------- KERNEL PANIC ----------\n"); let _ = uart.write_fmt(format_args!("FILE: {}\nLINE: {}\n COL: {}\n", file, line, col)); let _ = uart.write_fmt(format_args!("{}", msg)); loop { unsafe { asm!("wfe") } } }
identifier_body
panic.rs
use pi::uart::MiniUart; use core::fmt::{Write, Arguments}; #[lang = "eh_personality"] pub extern "C" fn eh_personality() {} #[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt(msg: Arguments, file: &'static str, line: u32, col: u32) ->! { let mut uart = MiniUart::new(); let _ = uart.write_str("\n\n---...
*dest.offset(i as isize) = *src.offset(i as isize); } } else { // copy from beginning let mut i = 0; while i < n { *dest.offset(i as isize) = *src.offset(i as isize); i += 1; } } return dest; } #[no_mangle] pub unsafe extern fn memset(s: *...
random_line_split
panic.rs
use pi::uart::MiniUart; use core::fmt::{Write, Arguments}; #[lang = "eh_personality"] pub extern "C" fn eh_personality() {} #[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt(msg: Arguments, file: &'static str, line: u32, col: u32) ->! { let mut uart = MiniUart::new(); let _ = uart.write_str("\n\n---...
else { // copy from beginning let mut i = 0; while i < n { *dest.offset(i as isize) = *src.offset(i as isize); i += 1; } } return dest; } #[no_mangle] pub unsafe extern fn memset(s: *mut u8, c: i32, n: usize) -> *mut u8 { let mut i = 0; while i < n { ...
{ // copy from end let mut i = n; while i != 0 { i -= 1; *dest.offset(i as isize) = *src.offset(i as isize); } }
conditional_block
fedora.rs
// Copyright 2015-2017 Intecture Developers. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distributed except according to those terms. use errors::*; use futures::{future, Future}; use pnet::datalink::interfaces; u...
impl TelemetryProvider for Fedora { fn available() -> bool { cfg!(target_os="linux") && linux::fingerprint_os() == Some(LinuxFlavour::Fedora) } fn load(&self) -> Box<Future<Item = Telemetry, Error = Error>> { Box::new(future::lazy(|| { let t = match do_load() { ...
use target::linux::LinuxFlavour; use telemetry::{Cpu, LinuxDistro, Os, OsFamily, OsPlatform, Telemetry}; pub struct Fedora;
random_line_split
fedora.rs
// Copyright 2015-2017 Intecture Developers. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distributed except according to those terms. use errors::*; use futures::{future, Future}; use pnet::datalink::interfaces; u...
() -> Result<Telemetry> { let (version_str, version_maj, version_min, version_patch) = redhat::version()?; Ok(Telemetry { cpu: Cpu { vendor: linux::cpu_vendor()?, brand_string: linux::cpu_brand_string()?, cores: linux::cpu_cores()?, }, fs: default::fs...
do_load
identifier_name
fedora.rs
// Copyright 2015-2017 Intecture Developers. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distributed except according to those terms. use errors::*; use futures::{future, Future}; use pnet::datalink::interfaces; u...
} fn do_load() -> Result<Telemetry> { let (version_str, version_maj, version_min, version_patch) = redhat::version()?; Ok(Telemetry { cpu: Cpu { vendor: linux::cpu_vendor()?, brand_string: linux::cpu_brand_string()?, cores: linux::cpu_cores()?, }, f...
{ Box::new(future::lazy(|| { let t = match do_load() { Ok(t) => t, Err(e) => return future::err(e), }; future::ok(t.into()) })) }
identifier_body