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
version.rs
use crate::internal::consts; // ========================================================================= // /// The CFB format version to use. #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum Version { /// Version 3, which uses 512-byte sectors. V3, /// Version 4, which uses 4...
(self) -> usize { self.sector_len() / consts::DIR_ENTRY_LEN } } // ========================================================================= // #[cfg(test)] mod tests { use super::Version; #[test] fn number_round_trip() { for &version in &[Version::V3, Version::V4] { asser...
dir_entries_per_sector
identifier_name
signals.rs
// Copyright 2020 The Exonum Team // // 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 i...
#[test] fn interrupt_node_with_http() { fork( "interrupt_node_with_http", rusty_fork_id!(), |_| {}, |child, output| check_child(child, output, Signal::SIGINT), || { let runtime = Runtime::new().unwrap(); runtime.block_on(start_node(16_460, true)); ...
{ fork( "interrupt_node_without_http", rusty_fork_id!(), |_| {}, |child, output| check_child(child, output, Signal::SIGINT), || { let runtime = Runtime::new().unwrap(); runtime.block_on(start_node(16_450, false)); }, ) .unwrap(); }
identifier_body
signals.rs
// Copyright 2020 The Exonum Team // // 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 i...
let (mut nodes, _) = run_nodes(1, start_port, options); let node = nodes.pop().unwrap(); node.run().await } fn check_child_with_custom_handler( child: &mut ChildWrapper, output: &mut File, http_port: Option<u16>, ) { // Sleep several seconds in order for the node to launch. check_chil...
{ options.http_start_port = Some(start_port + 1); }
conditional_block
signals.rs
// Copyright 2020 The Exonum Team // // 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 i...
.wait_timeout(Duration::from_secs(5)) .expect("Failed to wait for node to function"); if let Some(status) = maybe_status { panic!( "Node exited unexpectedly with this exit status: {:?}", status ); } } fn check_child_exit(child: &mut ChildWrapper, output: &m...
fn check_child_start(child: &mut ChildWrapper) { let maybe_status = child
random_line_split
signals.rs
// Copyright 2020 The Exonum Team // // 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 i...
() { fork( "interrupt_node_without_http", rusty_fork_id!(), |_| {}, |child, output| check_child(child, output, Signal::SIGINT), || { let runtime = Runtime::new().unwrap(); runtime.block_on(start_node(16_450, false)); }, ) .unwrap(); } #...
interrupt_node_without_http
identifier_name
borrowck-preserve-box-in-field.rs
// ignore-pretty // 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 lice...
// exec-env:RUST_POISON_ON_FREE=1 #![feature(managed_boxes)] fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; assert_eq!(before, after); } struct F { f: ~int } pub fn main() { let mut x = @F {f: ~3}; borrow(x.f, |b_x| { assert_eq!(*b_x, 3); assert_eq...
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
borrowck-preserve-box-in-field.rs
// ignore-pretty // 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 lice...
struct F { f: ~int } pub fn main() { let mut x = @F {f: ~3}; borrow(x.f, |b_x| { assert_eq!(*b_x, 3); assert_eq!(&(*x.f) as *int, &(*b_x) as *int); x = @F {f: ~4}; println!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); assert!(&(*x.f) as *int!= &(*b_x) as *in...
{ let before = *x; f(x); let after = *x; assert_eq!(before, after); }
identifier_body
borrowck-preserve-box-in-field.rs
// ignore-pretty // 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 lice...
(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; assert_eq!(before, after); } struct F { f: ~int } pub fn main() { let mut x = @F {f: ~3}; borrow(x.f, |b_x| { assert_eq!(*b_x, 3); assert_eq!(&(*x.f) as *int, &(*b_x) as *int); x = @F {f: ~4}; pri...
borrow
identifier_name
combine.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 ...
(&mut self, r: ty::Region) -> ty::Region { match r { // Never make variables for regions bound within the type itself. ty::ReLateBound(..) => { return r; } // Early-bound regions should really have been substituted away before // we get to this point. ...
fold_region
identifier_name
combine.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 ...
_ => { ty_fold::super_fold_ty(self, t) } } } fn fold_region(&mut self, r: ty::Region) -> ty::Region { match r { // Never make variables for regions bound within the type itself. ty::ReLateBound(..) => { return r; } //...
{ // Check to see whether the type we are genealizing references // `vid`. At the same time, also update any type variables to // the values that they are bound to. This is needed to truly // check for cycles, but also just makes things readable. // // (In particular, you...
identifier_body
combine.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 ...
self.clone().and_then(|s| { if s == t { self.clone() } else { Err(f()) } }) } } fn int_unification_error<'tcx>(a_is_expected: bool, v: (ty::IntVarValue, ty::IntVarValue)) -> ty::TypeError<'tcx> { ...
F: FnOnce() -> ty::TypeError<'tcx>, {
random_line_split
ui_helper.rs
use pbr::{MultiBar, Pipe, ProgressBar, Units}; use std::io::Stdout; use std::sync::Mutex; use std::thread; use std::time::Duration; lazy_static! { static ref TOTALS: Mutex<Vec<u64>> = Mutex::new(vec![]); static ref PBRS: Mutex<Vec<ProgressBar<Pipe>>> = Mutex::new(vec![]); } pub fn start_pbr(file_name: &str, l...
{ let mut pbrs = PBRS .lock() .expect("Failed to acquire PBRS lock, lock poisoned!"); let mut pb = mb.create_bar(size); pb.set_max_refresh_rate(Some(Duration::from_millis(200))); pb.tick_format("▏▎▍▌▋▊▉██▉▊▋▌▍▎▏"); pb.set_units(Units::Bytes); if let Some(msg) = message { ...
identifier_body
ui_helper.rs
use pbr::{MultiBar, Pipe, ProgressBar, Units}; use std::io::Stdout; use std::sync::Mutex; use std::thread; use std::time::Duration; lazy_static! { static ref TOTALS: Mutex<Vec<u64>> = Mutex::new(vec![]); static ref PBRS: Mutex<Vec<ProgressBar<Pipe>>> = Mutex::new(vec![]); } pub fn start_pbr(file_name: &str, l...
(bar_idx: usize) { finish_bar_with_message(bar_idx + 1, "Download Complete!"); } pub fn fail_bar(bar_idx: usize) { finish_bar_with_message(bar_idx + 1, "Download Failed!"); } fn finish_bar_with_message(act_bar: usize, message: &str) { PBRS.lock() .expect("Failed to acquire PBRS lock, lock poisoned!...
success_bar
identifier_name
ui_helper.rs
use pbr::{MultiBar, Pipe, ProgressBar, Units}; use std::io::Stdout; use std::sync::Mutex; use std::thread; use std::time::Duration; lazy_static! { static ref TOTALS: Mutex<Vec<u64>> = Mutex::new(vec![]); static ref PBRS: Mutex<Vec<ProgressBar<Pipe>>> = Mutex::new(vec![]); } pub fn start_pbr(file_name: &str, l...
.expect("Failed to acquire PBRS lock, lock poisoned!"); let mut pb = mb.create_bar(size); pb.set_max_refresh_rate(Some(Duration::from_millis(200))); pb.tick_format("▏▎▍▌▋▊▉██▉▊▋▌▍▎▏"); pb.set_units(Units::Bytes); if let Some(msg) = message { pb.show_message = true; pb.message...
random_line_split
ui_helper.rs
use pbr::{MultiBar, Pipe, ProgressBar, Units}; use std::io::Stdout; use std::sync::Mutex; use std::thread; use std::time::Duration; lazy_static! { static ref TOTALS: Mutex<Vec<u64>> = Mutex::new(vec![]); static ref PBRS: Mutex<Vec<ProgressBar<Pipe>>> = Mutex::new(vec![]); } pub fn start_pbr(file_name: &str, l...
= false; } pb.tick(); pbrs.push(pb); }
; pb.message(&msg); } else { pb.show_message
conditional_block
static.rs
// Copyright 2018 Kyle Mayes // // 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 w...
println!( "cargo:rustc-link-search=native={}", common::run_llvm_config(&["--libdir"]).unwrap().trim_end() ); for library in get_llvm_libraries() { println!("cargo:rustc-link-lib={}{}", prefix, library); } // Specify required system libraries. // MSVC doesn't need this, a...
{ let cep = common::CommandErrorPrinter::default(); let directory = find(); // Specify required Clang static libraries. println!("cargo:rustc-link-search=native={}", directory.display()); for library in get_clang_libraries(directory) { println!("cargo:rustc-link-lib=static={}", library); ...
identifier_body
static.rs
// Copyright 2018 Kyle Mayes // // 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 w...
<P: AsRef<Path>>(directory: P) -> Vec<String> { // Escape the directory in case it contains characters that have special // meaning in glob patterns (e.g., `[` or `]`). let directory = Pattern::escape(directory.as_ref().to_str().unwrap()); let directory = Path::new(&directory); let pattern = direct...
get_clang_libraries
identifier_name
static.rs
// Copyright 2018 Kyle Mayes // // 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 w...
} /// Returns a directory containing `libclang` static libraries. fn find() -> PathBuf { let name = if cfg!(target_os = "windows") { "libclang.lib" } else { "libclang.a" }; let files = common::search_libclang_directories(&[name.into()], "LIBCLANG_STATIC_PATH"); if let Some((direct...
{ CLANG_LIBRARIES.iter().map(|l| (*l).to_string()).collect() }
conditional_block
static.rs
// Copyright 2018 Kyle Mayes // // 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 w...
} else { "" }; // Specify required LLVM static libraries. println!( "cargo:rustc-link-search=native={}", common::run_llvm_config(&["--libdir"]).unwrap().trim_end() ); for library in get_llvm_libraries() { println!("cargo:rustc-link-lib={}{}", prefix, library); ...
// Determine the shared mode used by LLVM. let mode = common::run_llvm_config(&["--shared-mode"]).map(|m| m.trim().to_owned()); let prefix = if mode.map_or(false, |m| m == "static") { "static="
random_line_split
main.rs
use std::env; use std::process; use std::time::{Instant, Duration}; fn fibonacci_naive(n: u64) -> u64 { if n < 2 { n } else { fibonacci_naive(n-1) + fibonacci_naive(n-2) } } fn fibonacci_tailrec(n: u64, a: u64, b: u64) -> u64 { if n == 0 { a } else { fibonacci_tailr...
println!("{}", duration_in_sec(time2.elapsed())); let time3 = Instant::now(); let mut checksum_f3 = 0; for _ in 0..m { checksum_f3 += fibonacci_iterative(n); checksum_f3 %= 2147483647 } println!("{}", duration_in_sec(time3.elapsed())); println!("{}", f1); println!("{}",...
{ let args: Vec<_> = env::args().collect(); if args.len() != 3 { println!("Unexpected number of arguments."); process::exit(1); } let n = args[1].parse::<u64>().unwrap(); let m = args[2].parse::<u64>().unwrap(); let time1 = Instant::now(); let f1 = fibonacci_naive(n); p...
identifier_body
main.rs
use std::env; use std::process; use std::time::{Instant, Duration}; fn fibonacci_naive(n: u64) -> u64 { if n < 2 { n } else { fibonacci_naive(n-1) + fibonacci_naive(n-2) } } fn fibonacci_tailrec(n: u64, a: u64, b: u64) -> u64 { if n == 0 { a } else { fibonacci_tailr...
(d: Duration) -> f64 { (d.as_secs() as f64) + ((d.subsec_nanos() as f64) / 1_000_000_000 as f64) } fn main() { let args: Vec<_> = env::args().collect(); if args.len()!= 3 { println!("Unexpected number of arguments."); process::exit(1); } let n = args[1].parse::<u64>().unwrap(); ...
duration_in_sec
identifier_name
main.rs
use std::env; use std::process; use std::time::{Instant, Duration}; fn fibonacci_naive(n: u64) -> u64 { if n < 2 { n } else { fibonacci_naive(n-1) + fibonacci_naive(n-2) } } fn fibonacci_tailrec(n: u64, a: u64, b: u64) -> u64 { if n == 0 { a } else { fibonacci_tailr...
let args: Vec<_> = env::args().collect(); if args.len()!= 3 { println!("Unexpected number of arguments."); process::exit(1); } let n = args[1].parse::<u64>().unwrap(); let m = args[2].parse::<u64>().unwrap(); let time1 = Instant::now(); let f1 = fibonacci_naive(n); prin...
fn main() {
random_line_split
main.rs
use std::env; use std::process; use std::time::{Instant, Duration}; fn fibonacci_naive(n: u64) -> u64 { if n < 2 { n } else
} fn fibonacci_tailrec(n: u64, a: u64, b: u64) -> u64 { if n == 0 { a } else { fibonacci_tailrec(n-1, b, a+b) } } fn fibonacci_iterative(n_orig: u64) -> u64 { let mut a: u64 = 0; let mut b: u64 = 1; let mut n = n_orig; while n > 0 { // unclear if Rust supports synt...
{ fibonacci_naive(n-1) + fibonacci_naive(n-2) }
conditional_block
node.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/. */ //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency between layout and //! style. use cs...
fn prev_sibling(self) -> Option<Self>; fn next_sibling(self) -> Option<Self>; fn is_document(self) -> bool; fn is_element(self) -> bool; fn as_element(self) -> E; fn match_attr(self, attr: &AttrSelector, test: |&str| -> bool) -> bool; fn is_html_element_in_html_document(self) -> bool; f...
fn last_child(self) -> Option<Self>;
random_line_split
lfo.rs
use audiobuffer::*; use processblock::ProcessBlock; use synthconfig::SynthConfig; use port::Port; #[derive(Debug)] pub struct LFO{ phase: f32, sample_rate: f32, } pub const FREQ:Port = Port{nr:0}; pub const OUT:Port = Port{nr:0}; const MAX_FREQ:f32 = 5.0; impl LFO{ pub fn new() -> Box<LFO>{ Box:...
(&self) -> usize { 1 } fn port(&self, name: &str) -> Port{ match name { "output" => OUT, "freq" => FREQ, _ => panic!("Unknown port {}/{}", self.typename(), name) } } }
output_count
identifier_name
lfo.rs
use audiobuffer::*; use processblock::ProcessBlock; use synthconfig::SynthConfig; use port::Port; #[derive(Debug)] pub struct LFO{ phase: f32, sample_rate: f32, } pub const FREQ:Port = Port{nr:0}; pub const OUT:Port = Port{nr:0}; const MAX_FREQ:f32 = 5.0; impl LFO{ pub fn new() -> Box<LFO>{ Box:...
"freq" => FREQ, _ => panic!("Unknown port {}/{}", self.typename(), name) } } }
random_line_split
lib.rs
// Copyright (c) 2013-2017 Sandstorm Development Group, Inc. and contributors // // 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 right...
}
{ use capnp::traits::ImbueMut; let mut root: ::capnp::any_pointer::Builder = self.builder.get_root()?; root.imbue_mut(&mut self.cap_table); root.set_as(value) }
identifier_body
lib.rs
// Copyright (c) 2013-2017 Sandstorm Development Group, Inc. and contributors // // 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 right...
(&self) -> rpc::Disconnector<VatId> { rpc::Disconnector::new(self.connection_state.clone()) } } impl <VatId> Future for RpcSystem<VatId> where VatId:'static { type Item = (); type Error = Error; fn poll(&mut self) -> ::futures::Poll<Self::Item, Self::Error> { self.tasks.poll() } } ...
get_disconnector
identifier_name
lib.rs
// Copyright (c) 2013-2017 Sandstorm Development Group, Inc. and contributors // // 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 right...
//! //! ```capnp //! # Cap'n Proto schema //! interface Foo { //! identity @0 (x: UInt32) -> (y: UInt32); //! } //! ``` //! //! ```ignore //! // Rust server defining an implementation of Foo. //! struct FooImpl; //! impl foo::Server for FooImpl { //! fn identity(&mut self, //! params: foo::Ident...
//! An implementation of the [Cap'n Proto remote procedure call](https://capnproto.org/rpc.html) //! protocol. Includes all [Level 1](https://capnproto.org/rpc.html#protocol-features) features. //! //! # Example
random_line_split
isbn.rs
//! isbnid-rs //! Rust ISBN identifier library //! //! isbnid is a simple crate to handle ISBN identification numbers. //! isbnid will store, check and convert ISBNs in ISBN10, and ISBN13 //! formats and it will transform between them and output in URN form. //! isbnid can also output ISBN numbers with the correct hyph...
let nid: String = reis.replace_all(&id.to_uppercase(), "").into(); if nid.len() == 13 { if &nid[0..3]!= "978" && &nid[0..3]!= "979" { // Invalid Bookland code return Err(ISBNError::Bookland); } if u64::from_str(&nid[12..13]).unwrap()!=...
{ // Invalid ISBN format return Err(ISBNError::Format) }
conditional_block
isbn.rs
//! isbnid-rs //! Rust ISBN identifier library //! //! isbnid is a simple crate to handle ISBN identification numbers. //! isbnid will store, check and convert ISBNs in ISBN10, and ISBN13 //! formats and it will transform between them and output in URN form. //! isbnid can also output ISBN numbers with the correct hyph...
{ /// String doesn't form a valid ISBN10 or ISBN13 number encoding Format, /// ISBN Check digit is not valid CheckDigit, /// ISBN13 Bookland encoding (EAN-13) is different form 978 or 979, /// or it is 979 when converting to ISBN10 Bookland, /// ISBN doesn't belong to the ISBN Internati...
ISBNError
identifier_name
isbn.rs
//! isbnid-rs //! Rust ISBN identifier library //! //! isbnid is a simple crate to handle ISBN identification numbers. //! isbnid will store, check and convert ISBNs in ISBN10, and ISBN13 //! formats and it will transform between them and output in URN form. //! isbnid can also output ISBN numbers with the correct hyph...
let mut d = 0u64; for i in 1..10 { d = d + (10 - i) * (n % 10); n = n / 10; } d % 11 } fn digit13(id: &str) -> u64 { let mut n = u64::from_str(&id[0..12]).unwrap(); let mut d = 0u64; for i in 1..13 { d = d + (1 + 2 * (i % 2)) * (n % 10); n = n / 10; } ...
} fn digit10(id: &str) -> u64 { let mut n = u64::from_str(&id[0..9]).unwrap();
random_line_split
image.rs
/// According to glibc: /// ```c /// /* The x86-64 never uses Elf64_Rel/Elf32_Rel relocations. */ /// #define ELF_MACHINE_NO_REL 1 /// #define ELF_MACHINE_NO_RELA 0 /// ``` use std::fmt; use elf::header::Header; use elf::program_header::{self, ProgramHeader}; use elf::dyn::{self, Dyn}; use elf::sym::{self, Sym}; use g...
, _ => () } } let tls = if let Some(phdr) = tls_phdr { Some(lachesis.push_module(name, load_bias, phdr)) } else { None }; if let Some(vaddr) = dynamic_vaddr { let dynamic = dyn::from_raw(load_bias, vadd...
{ tls_phdr = Some(phdr); }
conditional_block
image.rs
/// According to glibc: /// ```c /// /* The x86-64 never uses Elf64_Rel/Elf32_Rel relocations. */ /// #define ELF_MACHINE_NO_REL 1 /// #define ELF_MACHINE_NO_RELA 0 /// ``` use std::fmt; use elf::header::Header; use elf::program_header::{self, ProgramHeader}; use elf::dyn::{self, Dyn}; use elf::sym::{self, Sym}; use g...
if let Some(vaddr) = dynamic_vaddr { let dynamic = dyn::from_raw(load_bias, vaddr); let link_info = dyn::DynamicInfo::new(dynamic, load_bias); // TODO: swap out the link_info syment with compile time constant SIZEOF_SYM? let num_syms = (link_i...
let tls = if let Some(phdr) = tls_phdr { Some(lachesis.push_module(name, load_bias, phdr)) } else { None };
random_line_split
image.rs
/// According to glibc: /// ```c /// /* The x86-64 never uses Elf64_Rel/Elf32_Rel relocations. */ /// #define ELF_MACHINE_NO_REL 1 /// #define ELF_MACHINE_NO_RELA 0 /// ``` use std::fmt; use elf::header::Header; use elf::program_header::{self, ProgramHeader}; use elf::dyn::{self, Dyn}; use elf::sym::{self, Sym}; use g...
load_bias: ptr, map_begin: 0, map_end: 0, libs: libs, phdrs: phdrs, dynamic: dynamic, symtab: symtab, strtab: strtab, relocations: relocations, pltrelocations: pltrelocations, pltgot: pltg...
{ let header = &*(ptr as *const Header); let phdrs = ProgramHeader::from_raw_parts((header.e_phoff as usize + ptr) as *const ProgramHeader, header.e_phnum as usize); let load_bias = compute_load_bias_wrapping(ptr, &phdrs); let dynamic = dyn::from_phdrs(load_bias, phdrs).unwrap(); ...
identifier_body
image.rs
/// According to glibc: /// ```c /// /* The x86-64 never uses Elf64_Rel/Elf32_Rel relocations. */ /// #define ELF_MACHINE_NO_REL 1 /// #define ELF_MACHINE_NO_RELA 0 /// ``` use std::fmt; use elf::header::Header; use elf::program_header::{self, ProgramHeader}; use elf::dyn::{self, Dyn}; use elf::sym::{self, Sym}; use g...
(base: usize, phdrs:&[ProgramHeader]) -> usize { for phdr in phdrs { if phdr.p_type == program_header::PT_LOAD { return base.wrapping_sub(phdr.p_vaddr.wrapping_add(phdr.p_offset) as usize); } } 0 } /// A `SharedObject` is either: /// 1. an mmap'd dynamic library which is explici...
compute_load_bias_wrapping
identifier_name
log-knows-the-names-of-variants-in-std.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...
}
check_log(exp, x);
random_line_split
log-knows-the-names-of-variants-in-std.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...
{ a(uint), b(String), } fn check_log<T: std::fmt::Show>(exp: String, v: T) { assert_eq!(exp, format!("{:?}", v)); } pub fn main() { let mut x = Some(foo::a(22u)); let exp = "Some(a(22u))".to_string(); let act = format!("{:?}", x); assert_eq!(act, exp); check_log(exp, x); x = None; ...
foo
identifier_name
log-knows-the-names-of-variants-in-std.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...
{ let mut x = Some(foo::a(22u)); let exp = "Some(a(22u))".to_string(); let act = format!("{:?}", x); assert_eq!(act, exp); check_log(exp, x); x = None; let exp = "None".to_string(); let act = format!("{:?}", x); assert_eq!(act, exp); check_log(exp, x); }
identifier_body
parser_testing.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(source_str : String) -> Option<P<ast::Item>> { with_error_checking_parse(source_str, |p| { p.parse_item() }) } /// Parse a string, return a stmt pub fn string_to_stmt(source_str : String) -> P<ast::Stmt> { with_error_checking_parse(source_str, |p| { p.parse_stmt().unwrap() }) } /// P...
string_to_item
identifier_name
parser_testing.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use ast; use parse::new_parse_sess; use parse::{ParseSess,string_to_filemap,filemap_to_tts}; use parse::new_parser_from_source_str; use parse::parser::Par...
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
random_line_split
parser_testing.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
/// Parse a string, return an item pub fn string_to_item (source_str : String) -> Option<P<ast::Item>> { with_error_checking_parse(source_str, |p| { p.parse_item() }) } /// Parse a string, return a stmt pub fn string_to_stmt(source_str : String) -> P<ast::Stmt> { with_error_checking_parse(source_...
{ with_error_checking_parse(source_str, |p| { p.parse_expr() }) }
identifier_body
main.rs
extern crate getopts; extern crate image; use getopts::{optopt,getopts}; use std::default::Default; use std::io::fs::File; use std::os::args; mod css; mod dom; mod html; mod layout; mod style; mod painting; #[allow(unstable)] fn
() { // Parse command-line options: let opts = [ optopt("h", "html", "HTML document", "FILENAME"), optopt("c", "css", "CSS stylesheet", "FILENAME"), optopt("o", "output", "Output file", "FILENAME"), ]; let matches = match getopts(args().tail(), &opts) { Ok(m) => m, ...
main
identifier_name
main.rs
extern crate getopts; extern crate image; use getopts::{optopt,getopts}; use std::default::Default; use std::io::fs::File; use std::os::args; mod css; mod dom; mod html; mod layout; mod style; mod painting; #[allow(unstable)] fn main()
let html = read_source(matches.opt_str("h"), "examples/test.html"); let css = read_source(matches.opt_str("c"), "examples/test.css"); // Since we don't have an actual window, hard-code the "viewport" size. let initial_containing_block = layout::Dimensions { content: layout::Rect { x: 0.0, y: 0...
{ // Parse command-line options: let opts = [ optopt("h", "html", "HTML document", "FILENAME"), optopt("c", "css", "CSS stylesheet", "FILENAME"), optopt("o", "output", "Output file", "FILENAME"), ]; let matches = match getopts(args().tail(), &opts) { Ok(m) => m, E...
identifier_body
main.rs
extern crate getopts; extern crate image; use getopts::{optopt,getopts}; use std::default::Default; use std::io::fs::File; use std::os::args; mod css; mod dom; mod html; mod layout; mod style; mod painting; #[allow(unstable)] fn main() { // Parse command-line options: let opts = [ optopt("h", "html",...
let root_node = html::parse(html); let stylesheet = css::parse(css); let style_root = style::style_tree(&root_node, &stylesheet); let layout_root = layout::layout_tree(&style_root, initial_containing_block); let canvas = painting::paint(&layout_root, initial_containing_block.content); // Create...
// Parsing and rendering:
random_line_split
set.rs
use std::io::BufReader; use std::fs; use std::rc; use sym; use exec::Arg; use exec::Redir; use shell::Shell; fn rd_set(_rd: Redir) -> i32 { println!("Redirection set is unimplemented"); 0 } fn set_spec(av: &mut Vec<Arg>) -> sym::ScopeSpec { let mut ret = sym::ScopeSpec::Default; while av.len() > 0 ...
// get args and keys let spec = set_spec(&mut args); let mut keyv = set_keys(&mut args); // filter out invalid keys let keyv = keyv.drain(..) .filter(|a| { a.find(|x| { if "?! {}()".contains(x) { //...
{ if args[0].is_rd() { let rd = args.remove(0).unwrap_rd(); return rd_set(rd); } }
conditional_block
set.rs
use std::io::BufReader; use std::fs; use std::rc; use sym; use exec::Arg; use exec::Redir; use shell::Shell; fn rd_set(_rd: Redir) -> i32 { println!("Redirection set is unimplemented"); 0 } fn set_spec(av: &mut Vec<Arg>) -> sym::ScopeSpec { let mut ret = sym::ScopeSpec::Default; while av.len() > 0 ...
for sl in flat_args.windows(2) { let ref elt = sl[0]; let ref lookahead = sl[1]; if lookahead == "..." { if vararg.is_some() { warn!("set: fn can have at most one vararg"); return 2; } vararg = Some(elt.to_owned()); ...
{ if av.len() == 0 || !av.last().unwrap().is_bl() { warn!("fn declaration must contain a block as its last arg."); return 2; } let exec_bl = av.pop().unwrap().unwrap_bl(); // TODO: patterns in function args! let mut args = Vec::new(); let mut vararg = None; let mut postargs...
identifier_body
set.rs
use std::io::BufReader; use std::fs; use std::rc; use sym; use exec::Arg; use exec::Redir; use shell::Shell; fn rd_set(_rd: Redir) -> i32 { println!("Redirection set is unimplemented"); 0 } fn set_spec(av: &mut Vec<Arg>) -> sym::ScopeSpec { let mut ret = sym::ScopeSpec::Default; while av.len() > 0 ...
// last arg if let Some(last) = flat_args.last() { if last!= "..." { if let Some(ref mut x) = postargs { x.push(last.to_owned()); } else { args.push(last.to_owned()); } } } for k in &kv { sh.st.set_fn(k, ...
} else { args.push(elt.to_owned()); } } }
random_line_split
set.rs
use std::io::BufReader; use std::fs; use std::rc; use sym; use exec::Arg; use exec::Redir; use shell::Shell; fn rd_set(_rd: Redir) -> i32 { println!("Redirection set is unimplemented"); 0 } fn set_spec(av: &mut Vec<Arg>) -> sym::ScopeSpec { let mut ret = sym::ScopeSpec::Default; while av.len() > 0 ...
() -> rc::Rc<Fn(Vec<Arg>, &mut Shell, Option<BufReader<fs::File>>) -> i32> { rc::Rc::new(|mut args: Vec<Arg>, sh: &mut Shell, _in: Option<BufReader<fs::File>>| -> i32 { // rd-set if args.len() == 1 { if args[0].is_rd() { let rd = args.remove(0).unwrap_rd(); ...
set_main
identifier_name
one_or_many.rs
//use serde::de::Deserialize; use super::super::link::HalLink; use super::super::resource::OneOrMany; use serde_json::{from_str, to_string}; use serde::*; #[derive(Serialize, Deserialize)] struct Boh { oom: OneOrMany<String> } #[test] fn ensure_one_object_gets_serialized_as_one() { let boh = Boh { oom: OneOrM...
{ let s = r#"{"oom":["test","test2"]}"#; let boh: Boh = from_str(s).unwrap(); assert_eq!(2, boh.oom.len()); assert_eq!("test", boh.oom.many()[0]); assert_eq!("test2", boh.oom.many()[1]); }
identifier_body
one_or_many.rs
//use serde::de::Deserialize; use super::super::link::HalLink; use super::super::resource::OneOrMany; use serde_json::{from_str, to_string}; use serde::*; #[derive(Serialize, Deserialize)] struct Boh { oom: OneOrMany<String> } #[test] fn ensure_one_object_gets_serialized_as_one() { let boh = Boh { oom: OneOrM...
() { let s = r#"{"oom":["test","test2"]}"#; let boh: Boh = from_str(s).unwrap(); assert_eq!(2, boh.oom.len()); assert_eq!("test", boh.oom.many()[0]); assert_eq!("test2", boh.oom.many()[1]); }
ensure_array_gets_deserialized
identifier_name
one_or_many.rs
//use serde::de::Deserialize; use super::super::link::HalLink; use super::super::resource::OneOrMany; use serde_json::{from_str, to_string}; use serde::*;
{ oom: OneOrMany<String> } #[test] fn ensure_one_object_gets_serialized_as_one() { let boh = Boh { oom: OneOrMany::new().with(&"test".to_owned()) }; assert_eq!(to_string(&boh).unwrap(), r#"{"oom":"test"}"#); } #[test] fn ensure_two_objects_get_serialized_as_array() { let boh = Boh { oom: OneOrMany::n...
#[derive(Serialize, Deserialize)] struct Boh
random_line_split
dead.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
typeck::MethodStatic(def_id) => { match ty::provided_source(self.tcx, def_id) { Some(p_did) => self.check_def_id(p_did), None => self.check_def_id(def_id) } } ...
Some(method) => { match method.origin {
random_line_split
dead.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn visit_node(&mut self, node: &ast_map::Node) { match *node { ast_map::NodeItem(item) => { match item.node { ast::ItemFn(..) | ast::ItemTy(..) | ast::ItemEnum(..) | ast::ItemStruct(..) ...
{ let mut scanned = HashSet::new(); while self.worklist.len() > 0 { let id = self.worklist.pop().unwrap(); if scanned.contains(&id) { continue } scanned.insert(id); match self.tcx.map.find(id) { Some(ref node) =...
identifier_body
dead.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a> { tcx: &'a ty::ctxt, live_symbols: Box<HashSet<ast::NodeId>>, } impl<'a> DeadVisitor<'a> { // id := node id of an item's definition. // ctor_id := `Some` if the item is a struct_ctor (tuple struct), // `None` otherwise. // If the item is a struct_ctor, then either its `id` or ...
DeadVisitor
identifier_name
def.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 name: ast::Name, // The name of the target. pub def_id: ast::DefId, // The definition of the target. } #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum MethodProvenance { FromTrait(ast::DefId), FromImpl(ast::DefId), } #[derive(Clone, Copy, PartialEq,...
Export
identifier_name
def.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 def_id: ast::DefId, // The definition of the target. } #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum MethodProvenance { FromTrait(ast::DefId), FromImpl(ast::DefId), } #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum...
pub struct Export { pub name: ast::Name, // The name of the target.
random_line_split
server_query.rs
use async_graphql::{Context, FieldResult}; use chrono::prelude::*; use eyre::{ // eyre, Result,
}; use printspool_json_store::{JsonRow, Record}; // use async_graphql::{ // // ID, // // Context, // FieldResult, // }; // use printspool_json_store::Record as _; use crate::{built_info, server::Server}; #[derive(Default)] pub struct ServerQuery; #[derive(async_graphql::InputObject, Default, Debug)] pub ...
// Context as _,
random_line_split
server_query.rs
use async_graphql::{Context, FieldResult}; use chrono::prelude::*; use eyre::{ // eyre, Result, // Context as _, }; use printspool_json_store::{JsonRow, Record}; // use async_graphql::{ // // ID, // // Context, // FieldResult, // }; // use printspool_json_store::Record as _; use crate::{built_i...
<'ctx>( &self, ctx: &'ctx Context<'_>, ) -> FieldResult<Option<String>> { let db: &crate::Db = ctx.data()?; async move { let servers = sqlx::query_as!( JsonRow, r#" SELECT servers.props FROM servers ...
server_name
identifier_name
server_query.rs
use async_graphql::{Context, FieldResult}; use chrono::prelude::*; use eyre::{ // eyre, Result, // Context as _, }; use printspool_json_store::{JsonRow, Record}; // use async_graphql::{ // // ID, // // Context, // FieldResult, // }; // use printspool_json_store::Record as _; use crate::{built_i...
; // eg. Teg 0.1.0 for linux/x86_64 format!( "Teg {version_number}{dirty_string}", version_number = version_number, dirty_string = dirty_string, ) } /// Returns the current date time from the server. Useful for determining the connection /// late...
{ "" }
conditional_block
server_query.rs
use async_graphql::{Context, FieldResult}; use chrono::prelude::*; use eyre::{ // eyre, Result, // Context as _, }; use printspool_json_store::{JsonRow, Record}; // use async_graphql::{ // // ID, // // Context, // FieldResult, // }; // use printspool_json_store::Record as _; use crate::{built_i...
// TODO: Do we need pending updates still in the new architecture? // hasPendingUpdates #[instrument(skip(self, ctx))] async fn server_name<'ctx>( &self, ctx: &'ctx Context<'_>, ) -> FieldResult<Option<String>> { let db: &crate::Db = ctx.data()?; async move { ...
{ Utc::now() }
identifier_body
config.rs
use std::{io, fmt, os, result, mem}; use std::collections::HashMap; use serialize::{Encodable,Encoder}; use toml; use core::MultiShell; use util::{CargoResult, ChainError, Require, internal, human}; use util::toml as cargo_toml; pub struct Config<'a> { home_path: Path, shell: &'a mut MultiShell<'a>, jobs:...
|_, old, new| err = old.merge(new), |_, new| new); try!(err); } } (expected, found) => { return Err(internal(format!("expected {}, but found {}", ...
for (key, value) in new.move_iter() { let mut err = Ok(()); old.find_with_or_insert_with(key, value,
random_line_split
config.rs
use std::{io, fmt, os, result, mem}; use std::collections::HashMap; use serialize::{Encodable,Encoder}; use toml; use core::MultiShell; use util::{CargoResult, ChainError, Require, internal, human}; use util::toml as cargo_toml; pub struct
<'a> { home_path: Path, shell: &'a mut MultiShell<'a>, jobs: uint, target: Option<String>, linker: Option<String>, ar: Option<String>, } impl<'a> Config<'a> { pub fn new<'a>(shell: &'a mut MultiShell, jobs: Option<uint>, target: Option<String>) -> Cargo...
Config
identifier_name
config.rs
use std::{io, fmt, os, result, mem}; use std::collections::HashMap; use serialize::{Encodable,Encoder}; use toml; use core::MultiShell; use util::{CargoResult, ChainError, Require, internal, human}; use util::toml as cargo_toml; pub struct Config<'a> { home_path: Path, shell: &'a mut MultiShell<'a>, jobs:...
pub fn desc(&self) -> &'static str { match *self { Table(..) => "table", List(..) => "array", String(..) => "string", Boolean(..) => "boolean", } } } pub fn get_config(pwd: Path, key: &str) -> CargoResult<ConfigValue> { find_in_tree(&pwd, |f...
{ match *self { Boolean(b, ref p) => Ok((b, p)), _ => Err(internal(format!("expected a bool, but found a {}", self.desc()))), } }
identifier_body
mtf.rs
/*! MTF (Move To Front) encoder/decoder Produces a rank for each input character based on when it was seen last time. Useful for BWT output encoding, which produces a lot of zeroes and low ranks. # Links http://en.wikipedia.org/wiki/Move-to-front_transform # Example ```rust use std::io::{self, Read, Write}; use co...
(self) -> W { self.w } } impl<W: Write> Write for Encoder<W> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { for sym in buf.iter() { let rank = self.mtf.encode(*sym); try!(self.w.write_u8(rank)); } Ok(buf.len()) } fn flush(&mut self) -> ...
finish
identifier_name
mtf.rs
/*! MTF (Move To Front) encoder/decoder Produces a rank for each input character based on when it was seen last time. Useful for BWT output encoding, which produces a lot of zeroes and low ranks. # Links http://en.wikipedia.org/wiki/Move-to-front_transform # Example ```rust use std::io::{self, Read, Write}; use co...
}
{ let vec = Vec::new(); let input = include_bytes!("../data/test.txt"); let mut e = Encoder::new(io::BufWriter::new(vec)); e.write_all(input).unwrap(); let encoded = e.finish().into_inner().unwrap(); bh.iter(|| { let mut d = Decoder::new(io::BufReader::new(&en...
identifier_body
mtf.rs
/*! MTF (Move To Front) encoder/decoder Produces a rank for each input character based on when it was seen last time. Useful for BWT output encoding, which produces a lot of zeroes and low ranks. # Links http://en.wikipedia.org/wiki/Move-to-front_transform # Example ```rust use std::io::{self, Read, Write}; use co...
let mut rank: Rank = 1; loop { mem::swap(&mut self.symbols[rank as usize], &mut next); if next == sym { break; } rank += 1; assert!((rank as usize) < self.symbols.len()); } self.symbols[0] = sym; rank ...
{ return 0 }
conditional_block
mtf.rs
/*! MTF (Move To Front) encoder/decoder Produces a rank for each input character based on when it was seen last time. Useful for BWT output encoding, which produces a lot of zeroes and low ranks. # Links http://en.wikipedia.org/wiki/Move-to-front_transform # Example ```rust use std::io::{self, Read, Write}; use co...
let mut next = self.symbols[0]; if next == sym { return 0 } let mut rank: Rank = 1; loop { mem::swap(&mut self.symbols[rank as usize], &mut next); if next == sym { break; } rank += 1; assert!(...
/// encode a symbol into its rank pub fn encode(&mut self, sym: Symbol) -> Rank {
random_line_split
crateresolve4b-2.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 ...
() -> int { crateresolve4a::f() }
g
identifier_name
crateresolve4b-2.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 ...
{ crateresolve4a::f() }
identifier_body
crateresolve4b-2.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:crateresolve4a-1.rs // aux-build:crateresolve4a-2.rs #![crate_name="crateresolve4b#0.2"] #![crate_type = "lib"] extern crate "crateresolve4a...
random_line_split
activation.rs
// Copyright © 2017 winapi-rs developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied, modi...
use um::winnt::{HRESULT}; use winrt::inspectable::{IInspectable, IInspectableVtbl}; RIDL!{#[uuid(0x00000035, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface IActivationFactory(IActivationFactoryVtbl): IInspectable(IInspectableVtbl) { fn ActivateInstance( instance: *mut *mut IInspe...
// except according to those terms.
random_line_split
font.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 geom::{Point2D, Rect, Size2D}; use std::borrow::ToOwned; use std::mem; use std::slice; use std::rc::Rc;
use std::cell::RefCell; use util::cache::HashCache; use util::smallvec::{SmallVec, SmallVec8}; use style::computed_values::{font_stretch, font_variant, font_weight}; use style::properties::style_structs::Font as FontStyle; use std::sync::Arc; use platform::font_context::FontContextHandle; use platform::font::{FontHand...
random_line_split
font.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 geom::{Point2D, Rect, Size2D}; use std::borrow::ToOwned; use std::mem; use std::slice; use std::rc::Rc; use st...
(advance: Au, ascent: Au, descent: Au) -> RunMetrics { let bounds = Rect(Point2D(Au(0), -ascent), Size2D(advance, ascent + descent)); // TODO(Issue #125): support loose and tight bounding boxes; using the // ascent+descent and advance is sometimes too generous and ...
new
identifier_name
font.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 geom::{Point2D, Rect, Size2D}; use std::borrow::ToOwned; use std::mem; use std::slice; use std::rc::Rc; use st...
else { "Didn't find" }; debug!("{} font table[{}] with family={}, face={}", status, tag.tag_to_str(), self.handle.family_name(), self.handle.face_name()); return result; } pub fn glyph_index(&self, codepoint: char) -> Option<GlyphId> { let codepoint = ma...
{ "Found" }
conditional_block
objc_category.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #![cfg(target_os = "macos")] #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] #[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref f...
} }
random_line_split
objc_category.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #![cfg(target_os = "macos")] #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] #[derive(Clone)] pub struct
(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; fn deref(&self) -> &Self::Target { unsafe { &*self.0 } } } unsafe impl objc::Message for Foo {} impl Foo { pub fn alloc() -> Self { Self(unsafe { msg_send!(objc::class!(Foo), alloc) }) } } impl IFoo for Foo...
Foo
identifier_name
objc_category.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #![cfg(target_os = "macos")] #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] #[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref f...
}
{ msg_send!(*self, categoryMethod) }
identifier_body
stdlib_demo.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use diem_framework::{encode_peer_to_peer_with_metadata_script, ScriptCall}; use diem_types::{AccountAddress, Identifier, StructTag, TypeTag}; use serde_bytes::ByteBuf as Bytes; fn main() { let token = TypeTag::Struct(StructTag { ...
_ => panic!("unexpected type of script"), } let output = bcs::to_bytes(&script).unwrap(); for o in output { print!("{} ", o); } println!(); }
{ assert_eq!(a, amount); assert_eq!(p, payee); }
conditional_block
stdlib_demo.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use diem_framework::{encode_peer_to_peer_with_metadata_script, ScriptCall}; use diem_types::{AccountAddress, Identifier, StructTag, TypeTag}; use serde_bytes::ByteBuf as Bytes; fn main() { let token = TypeTag::Struct(StructTag { ...
}
random_line_split
stdlib_demo.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use diem_framework::{encode_peer_to_peer_with_metadata_script, ScriptCall}; use diem_types::{AccountAddress, Identifier, StructTag, TypeTag}; use serde_bytes::ByteBuf as Bytes; fn main()
let call = ScriptCall::decode(&script); match call { Some(ScriptCall::PeerToPeerWithMetadata { amount: a, payee: p, .. }) => { assert_eq!(a, amount); assert_eq!(p, payee); } _ => panic!("unexpected type of script"), }...
{ let token = TypeTag::Struct(StructTag { address: AccountAddress([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), module: Identifier("XDX".into()), name: Identifier("XDX".into()), type_params: Vec::new(), }); let payee = AccountAddress([ 0x22, 0x22, 0x22, 0x22, 0x2...
identifier_body
stdlib_demo.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use diem_framework::{encode_peer_to_peer_with_metadata_script, ScriptCall}; use diem_types::{AccountAddress, Identifier, StructTag, TypeTag}; use serde_bytes::ByteBuf as Bytes; fn
() { let token = TypeTag::Struct(StructTag { address: AccountAddress([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), module: Identifier("XDX".into()), name: Identifier("XDX".into()), type_params: Vec::new(), }); let payee = AccountAddress([ 0x22, 0x22, 0x22, 0x22, ...
main
identifier_name
associated-types-doubleendediterator-object.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 v = vec![1, 2, 3, 4, 5, 6]; let r = pairwise_sub(Box::new(v.into_iter())); assert_eq!(r, 9); }
{ return result; }
conditional_block
associated-types-doubleendediterator-object.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 v = vec![1, 2, 3, 4, 5, 6]; let r = pairwise_sub(Box::new(v.into_iter())); assert_eq!(r, 9); }
{ let mut result = 0; loop { let front = t.next(); let back = t.next_back(); match (front, back) { (Some(f), Some(b)) => { result += b - f; } _ => { return result; } } } }
identifier_body
associated-types-doubleendediterator-object.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 ...
(mut t: Box<DoubleEndedIterator<Item=isize>>) -> isize { let mut result = 0; loop { let front = t.next(); let back = t.next_back(); match (front, back) { (Some(f), Some(b)) => { result += b - f; } _ => { return result; } } } } fn main() { let v = ...
pairwise_sub
identifier_name
associated-types-doubleendediterator-object.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 v = vec![1, 2, 3, 4, 5, 6]; let r = pairwise_sub(Box::new(v.into_iter())); assert_eq!(r, 9); }
_ => { return result; } } } }
random_line_split
value.rs
use super::MysqlType; use crate::deserialize; use crate::mysql::types::MYSQL_TIME; use std::error::Error; /// Raw mysql value as received from the database #[derive(Copy, Clone, Debug)] pub struct MysqlValue<'a> { raw: &'a [u8], tpe: MysqlType, } impl<'a> MysqlValue<'a> { pub(crate) fn new(raw: &'a [u8], ...
Decimal(&'a [u8]), }
/// Correponds to `MYSQL_TYPE_DECIMAL` and `MYSQL_TYPE_NEWDECIMAL`
random_line_split
value.rs
use super::MysqlType; use crate::deserialize; use crate::mysql::types::MYSQL_TIME; use std::error::Error; /// Raw mysql value as received from the database #[derive(Copy, Clone, Debug)] pub struct MysqlValue<'a> { raw: &'a [u8], tpe: MysqlType, } impl<'a> MysqlValue<'a> { pub(crate) fn new(raw: &'a [u8], ...
(&self) -> MysqlType { self.tpe } /// Checks that the type code is valid, and interprets the data as a /// `MYSQL_TIME` pointer // We use `ptr.read_unaligned()` to read the potential unaligned ptr, // so clippy is clearly wrong here // https://github.com/rust-lang/rust-clippy/issues/288...
value_type
identifier_name
logger.rs
use config::Config; use log::{self, Log, LogLevel, LogLevelFilter, LogMetadata, LogRecord, SetLoggerError}; use monitor::{Monitor, MonitorProvider}; pub fn start_logging(config: &Config) -> Result<(), SetLoggerError> { log::set_logger(|max_log_level| { max_log_level.set(LogLevelFilter::Info); if l...
}
{ if self.enabled(record.metadata()) { let error_message = format!("{} - {}", record.level(), record.args()); if record.level() == LogLevel::Error { self.monitor.send(&error_message, record.location()); } println!("{}", error_message); } ...
identifier_body
logger.rs
use config::Config; use log::{self, Log, LogLevel, LogLevelFilter, LogMetadata, LogRecord, SetLoggerError}; use monitor::{Monitor, MonitorProvider}; pub fn start_logging(config: &Config) -> Result<(), SetLoggerError> { log::set_logger(|max_log_level| { max_log_level.set(LogLevelFilter::Info); if l...
} impl<T: Monitor> Log for Logger<T> { fn enabled(&self, metadata: &LogMetadata) -> bool { metadata.level() <= LogLevel::Info } fn log(&self, record: &LogRecord) { if self.enabled(record.metadata()) { let error_message = format!("{} - {}", record.level(), record.args()); ...
struct Logger<T: Monitor> { monitor: T,
random_line_split
logger.rs
use config::Config; use log::{self, Log, LogLevel, LogLevelFilter, LogMetadata, LogRecord, SetLoggerError}; use monitor::{Monitor, MonitorProvider}; pub fn start_logging(config: &Config) -> Result<(), SetLoggerError> { log::set_logger(|max_log_level| { max_log_level.set(LogLevelFilter::Info); if l...
None => { panic!("Monitor {} has not been found.", monitor.provider); } }; } } Box::new(Logger { monitor: MonitorProvider::null_monitor(), }) }) } struct Logger<T: Monitor> { monito...
{ return Box::new(Logger { monitor: monitor }); }
conditional_block
logger.rs
use config::Config; use log::{self, Log, LogLevel, LogLevelFilter, LogMetadata, LogRecord, SetLoggerError}; use monitor::{Monitor, MonitorProvider}; pub fn
(config: &Config) -> Result<(), SetLoggerError> { log::set_logger(|max_log_level| { max_log_level.set(LogLevelFilter::Info); if let Some(monitor) = config.monitor.to_owned() { if monitor.enabled == true { match MonitorProvider::find_with_config(&monitor.provider, &monito...
start_logging
identifier_name
utils.rs
extern crate delivery; extern crate log; use delivery::utils; use delivery::utils::path_join_many::PathJoinMany; use std::fs; use std::path::Path; use support::paths::fixture_file; use tempdir::TempDir; macro_rules! setup { () => {}; } test!(copy_recursive { let source_dir = fixture_file("test_repo"); le...
<P:?Sized>(f: &P) -> bool where P: AsRef<Path>, { fs::metadata(f).is_ok() }
file_exists
identifier_name
utils.rs
extern crate delivery; extern crate log; use delivery::utils; use delivery::utils::path_join_many::PathJoinMany; use std::fs; use std::path::Path; use support::paths::fixture_file; use tempdir::TempDir; macro_rules! setup { () => {}; } test!(copy_recursive { let source_dir = fixture_file("test_repo"); le...
&["test_repo", "README.md"], &["test_repo", "cookbooks", "delivery_test", "metadata.rb"], &["test_repo", "cookbooks", "delivery_test", "recipes", "unit.rb"]]; for e in expected { if!file_exists(&dest_dir.join_many(e)) { panic!(format!("copy_recursive failure: NOT FOUND '...
let expected: &[&[&str]] = &[
random_line_split
utils.rs
extern crate delivery; extern crate log; use delivery::utils; use delivery::utils::path_join_many::PathJoinMany; use std::fs; use std::path::Path; use support::paths::fixture_file; use tempdir::TempDir; macro_rules! setup { () => {}; } test!(copy_recursive { let source_dir = fixture_file("test_repo"); le...
{ fs::metadata(f).is_ok() }
identifier_body
exports.rs
//! Parse the PE export table (if present) to find entries in find exports in //! executable sections. //! //! PEs may export data, which we'll assume isn't in an executable section. use anyhow::Result; use crate::{loader::pe::PE, module::Permissions, VA}; pub fn find_pe_exports(pe: &PE) -> Result<Vec<VA>> { let ...
#[test] fn nop() -> Result<()> { let buf = get_buf(Rsrc::NOP); let pe = crate::loader::pe::PE::from_bytes(&buf)?; let fns = crate::analysis::pe::exports::find_pe_exports(&pe)?; assert_eq!(0, fns.len()); Ok(()) } #[test] fn mimi() -> Result<()> { l...
{ let buf = get_buf(Rsrc::TINY); let pe = crate::loader::pe::PE::from_bytes(&buf)?; let fns = crate::analysis::pe::exports::find_pe_exports(&pe)?; assert_eq!(0, fns.len()); Ok(()) }
identifier_body
exports.rs
//! Parse the PE export table (if present) to find entries in find exports in //! executable sections. //! //! PEs may export data, which we'll assume isn't in an executable section. use anyhow::Result; use crate::{loader::pe::PE, module::Permissions, VA}; pub fn find_pe_exports(pe: &PE) -> Result<Vec<VA>> { let ...
fn k32() -> Result<()> { let buf = get_buf(Rsrc::K32); let pe = crate::loader::pe::PE::from_bytes(&buf)?; let fns = crate::analysis::pe::exports::find_pe_exports(&pe)?; assert_eq!(1445, fns.len()); Ok(()) } #[test] fn tiny() -> Result<()> { let buf = ge...
#[test]
random_line_split
exports.rs
//! Parse the PE export table (if present) to find entries in find exports in //! executable sections. //! //! PEs may export data, which we'll assume isn't in an executable section. use anyhow::Result; use crate::{loader::pe::PE, module::Permissions, VA}; pub fn find_pe_exports(pe: &PE) -> Result<Vec<VA>> { let ...
() -> Result<()> { let buf = get_buf(Rsrc::NOP); let pe = crate::loader::pe::PE::from_bytes(&buf)?; let fns = crate::analysis::pe::exports::find_pe_exports(&pe)?; assert_eq!(0, fns.len()); Ok(()) } #[test] fn mimi() -> Result<()> { let buf = get_buf(Rsrc::M...
nop
identifier_name
uct_test.rs
use crate::uct::{UcbType, UctConfig, UctKomiType, UctRoot}; use oppai_field::construct_field::construct_field; use oppai_field::field::NonZeroPos; use oppai_field::player::Player; use oppai_test_images::*; use rand::SeedableRng; use rand_xoshiro::Xoshiro256PlusPlus; use std::sync::atomic::AtomicBool; const UCT_CONFIG:...
depth: 8, komi_type: UctKomiType::Dynamic, red: 0.45, green: 0.5, komi_min_iterations: 3_000, }; macro_rules! uct_test { ($(#[$($attr:meta),+])* $name:ident, $image:ident, $iterations:expr, $seed:expr) => { #[test] $(#[$($attr),+])* fn $name() { env_logger::try_init().ok(); let mut ...
random_line_split
main.rs
//! Demonstrates the use of service accounts and the Google Cloud Pubsub API. //! //! Run this binary as.../service_account pub 'your message' in order to publish messages, //! and as.../service_account sub in order to subscribe to those messages. This will look like the //! following: //! //! ``` //! $ target/debug/se...
Ok(_) => (), } } // Wait for new messages. Print and ack any new messages. fn subscribe_wait(methods: &PubsubMethods) { check_or_create_subscription(&methods); let request = pubsub::PullRequest { return_immediately: Some(false), max_messages: Some(1), }; loop { l...
{ println!("Ack error: {:?}", e); }
conditional_block