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
thread.rs
// // Copyright (c) 2011-2017, UDI Contributors // All rights reserved. // // 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/. // #![deny(warnings)] #![allow(unused_varia...
} impl PartialEq for Thread { fn eq(&self, other: &Thread) -> bool { self.tid == other.tid } }
{ let ctx = match self.file_context.as_mut() { Some(ctx) => ctx, None => { let msg = format!("Thread {:?} terminated, cannot performed requested operation", self.tid); return Err(ErrorKind::Request(msg).into()); ...
identifier_body
thread.rs
// // Copyright (c) 2011-2017, UDI Contributors // All rights reserved. // // 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/. // #![deny(warnings)] #![allow(unused_varia...
(&mut self, setting: bool) -> Result<()> { let msg = request::SingleStep::new(setting); let resp: response::SingleStep = self.send_request(&msg)?; self.single_step = setting; Ok(()) } pub fn get_single_step(&self) -> bool { self.single_step } pub fn get_next_...
set_single_step
identifier_name
wrong_transmute.rs
use super::WRONG_TRANSMUTE; use clippy_utils::diagnostics::span_lint; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; /// Checks for `wrong_transmute` lint. /// Returns `true` if it's triggered, otherwise returns `false`. pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Ex...
}
}
random_line_split
wrong_transmute.rs
use super::WRONG_TRANSMUTE; use clippy_utils::diagnostics::span_lint; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; /// Checks for `wrong_transmute` lint. /// Returns `true` if it's triggered, otherwise returns `false`. pub(super) fn
<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) -> bool { match (&from_ty.kind(), &to_ty.kind()) { (ty::Float(_) | ty::Char, ty::Ref(..) | ty::RawPtr(_)) => { span_lint( cx, WRONG_TRANSMUTE, e.span, ...
check
identifier_name
wrong_transmute.rs
use super::WRONG_TRANSMUTE; use clippy_utils::diagnostics::span_lint; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; /// Checks for `wrong_transmute` lint. /// Returns `true` if it's triggered, otherwise returns `false`. pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Ex...
{ match (&from_ty.kind(), &to_ty.kind()) { (ty::Float(_) | ty::Char, ty::Ref(..) | ty::RawPtr(_)) => { span_lint( cx, WRONG_TRANSMUTE, e.span, &format!("transmute from a `{}` to a pointer", from_ty), ); true ...
identifier_body
default.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 ...
//! B, //! C, //! } //! //! impl Default for Kind { //! fn default() -> Kind { Kind::A } //! } //! //! #[derive(Default)] //! struct SomeOptions { //! foo: int, //! bar: f32, //! baz: Kind, //! } //! //! //! fn main() { //! let options: SomeOptions = Default::default(); //! } //! ``` //! //!...
//! //! enum Kind { //! A,
random_line_split
coding.rs
/* Copyright 2015 Tyler Neely 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 wri...
} true } quickcheck(prop as fn(Vec<u32>) -> bool); } #[test] fn equiv_u64() { use self::quickcheck::quickcheck; fn prop(xs: Vec<u64>) -> bool { for x in xs { if x!= decode_u64(encode_u64(x)) { return false } } true } ...
{ return false }
conditional_block
coding.rs
/* Copyright 2015 Tyler Neely 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 wri...
pub fn decode_u32(buf: [u8; 4]) -> u32 { ((buf[0] & 0xff).to_u32().unwrap() << 24) | ((buf[1] & 0xff).to_u32().unwrap() << 16) | ((buf[2] & 0xff).to_u32().unwrap() << 8) | ((buf[3] & 0xff)).to_u32().unwrap() } pub fn encode_u64(frameSize: u64) -> [u8; 8] { let mut buf = [0u8; 8]; buf[0] = (0...
{ let mut buf = [0u8; 4]; buf[0] = (0xff & (frameSize >> 24)).to_u8().unwrap(); buf[1] = (0xff & (frameSize >> 16)).to_u8().unwrap(); buf[2] = (0xff & (frameSize >> 8)).to_u8().unwrap(); buf[3] = (0xff & (frameSize)).to_u8().unwrap(); buf }
identifier_body
coding.rs
/* Copyright 2015 Tyler Neely 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 wri...
*/ extern crate quickcheck; use std::num::ToPrimitive; pub fn encode_u32(frameSize: u32) -> [u8; 4] { let mut buf = [0u8; 4]; buf[0] = (0xff & (frameSize >> 24)).to_u8().unwrap(); buf[1] = (0xff & (frameSize >> 16)).to_u8().unwrap(); buf[2] = (0xff & (frameSize >> 8)).to_u8().unwrap(); buf[3] = (0x...
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
random_line_split
coding.rs
/* Copyright 2015 Tyler Neely 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 wri...
(buf: [u8; 8]) -> u64 { ((buf[0] & 0xff).to_u64().unwrap() << 56) | ((buf[1] & 0xff).to_u64().unwrap() << 48) | ((buf[2] & 0xff).to_u64().unwrap() << 40) | ((buf[3] & 0xff).to_u64().unwrap() << 32) | ((buf[4] & 0xff).to_u64().unwrap() << 24) | ((buf[5] & 0xff).to_u64().unwrap() << 16) | ((bu...
decode_u64
identifier_name
noise.rs
use num_traits; use num_traits::NumCast; #[cfg(feature = "noise")] use noise::{NoiseModule, Perlin, Seedable}; fn cast<T: NumCast, R: NumCast>(val: T) -> R { num_traits::cast(val).unwrap() } #[cfg(feature = "noise")] pub struct Noise { perlin: Perlin, } #[cfg(feature = "noise")] impl Noise { pub fn new...
(&mut self, seed: u32) { } }
set_seed
identifier_name
noise.rs
use num_traits; use num_traits::NumCast; #[cfg(feature = "noise")] use noise::{NoiseModule, Perlin, Seedable}; fn cast<T: NumCast, R: NumCast>(val: T) -> R { num_traits::cast(val).unwrap() } #[cfg(feature = "noise")] pub struct Noise { perlin: Perlin, } #[cfg(feature = "noise")] impl Noise { pub fn new...
pub fn set_seed(&mut self, seed: u32) { } }
{ 0. }
identifier_body
noise.rs
use num_traits; use num_traits::NumCast; #[cfg(feature = "noise")] use noise::{NoiseModule, Perlin, Seedable}; fn cast<T: NumCast, R: NumCast>(val: T) -> R { num_traits::cast(val).unwrap() } #[cfg(feature = "noise")] pub struct Noise { perlin: Perlin,
info!("[Unicorn][Noise] new"); Noise { perlin: Perlin::new() } } pub fn get(&mut self, x: f64, y: f64, z: f64) -> f64 { let r: f64 = cast(self.perlin.get([x, y, z])); r } pub fn set_seed(&mut self, seed: u32) { debug!("Change seed to {:?}", seed); self.p...
} #[cfg(feature = "noise")] impl Noise { pub fn new() -> Noise {
random_line_split
local.rs
fn construct_output_snapshot( store: Store, posix_fs: Arc<fs::PosixFS>, output_file_paths: BTreeSet<RelativePath>, output_dir_paths: BTreeSet<RelativePath>, ) -> BoxFuture<'static, Result<Snapshot, String>> { let output_paths: Result<Vec<String>, String> = output_dir_paths .into_iter() ...
} // TODO: A Stream that ends with `Exit` is error prone: we should consider creating a Child struct // similar to nails::server::Child (which is itself shaped like `std::process::Child`). // See https://github.com/stuhood/nails/issues/1 for more info. #[derive(Debug, PartialEq, Eq)] pub enum ChildOutput { Stdout(B...
{ self .inner .stdin(Stdio::null()) .stdout(stdout) .stderr(stderr) .spawn() }
identifier_body
local.rs
fn construct_output_snapshot( store: Store, posix_fs: Arc<fs::PosixFS>, output_file_paths: BTreeSet<RelativePath>, output_dir_paths: BTreeSet<RelativePath>, ) -> BoxFuture<'static, Result<Snapshot, String>> { let output_paths: Result<Vec<String>, String> = output_dir_paths .into_iter() ...
<O: Into<Stdio>, E: Into<Stdio>>( &mut self, stdout: O, stderr: E, ) -> std::io::Result<Child> { self .inner .stdin(Stdio::null()) .stdout(stdout) .stderr(stderr) .spawn() } } // TODO: A Stream that ends with `Exit` is error prone: we should consider creating a Child struct...
spawn
identifier_name
local.rs
fn construct_output_snapshot( store: Store, posix_fs: Arc<fs::PosixFS>, output_file_paths: BTreeSet<RelativePath>, output_dir_paths: BTreeSet<RelativePath>, ) -> BoxFuture<'static, Result<Snapshot, String>> { let output_paths: Result<Vec<String>, String> = output_dir_paths .into_iter() ...
else { workdir_path.clone() }; // Use no ignore patterns, because we are looking for explicitly listed paths. let posix_fs = Arc::new( fs::PosixFS::new(root, fs::GitignoreStyleExcludes::empty(), executor.clone()).map_err( |err| { format!( "Error mak...
{ workdir_path.join(working_directory) }
conditional_block
local.rs
// TODO: This will not universally prevent child processes continuing to run in the // background, because killing a pantsd client with Ctrl+C kills the server with a signal, // which won't currently result in an orderly dropping of everything in the graph. See #10004. .kill_on_drop(true) .env_c...
let res: Result<_, String> = Ok(exe_was_materialized); res })
random_line_split
dsound.rs
// Copyright © 2015-2017 winapi-rs developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied,...
DEFINE_GUID!{DSDEVID_DefaultVoiceCapture, 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03} STRUCT!{struct DSCAPS { dwSize: DWORD, dwFlags: DWORD, dwMinSecondarySampleRate: DWORD, dwMaxSecondarySampleRate: DWORD, dwPrimaryBuffers: DWORD, dwMaxHwMixingAllBuffers: DWO...
0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03}
random_line_split
service.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity 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 la...
let io = IoContext::new(self.io_service.channel(), 0); let host = self.host.read(); host.as_ref().map(|ref host| host.with_context_eval(protocol, &io, action)) } } impl MayPanic for NetworkService { fn on_panic<F>(&self, closure: F) where F: OnPanicListener { self.panic_handler.on_panic(closure); } }
random_line_split
service.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity 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 la...
<F>(&self, closure: F) where F: OnPanicListener { self.panic_handler.on_panic(closure); } }
on_panic
identifier_name
service.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity 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 la...
/// Returns host identifier string as advertised to other peers pub fn host_info(&self) -> String { self.host_info.clone() } /// Returns underlying io service. pub fn io(&self) -> &IoService<NetworkIoMessage> { &self.io_service } /// Returns network statistics. pub fn stats(&self) -> &NetworkStats { &...
{ self.io_service.send_message(NetworkIoMessage::AddHandler { handler: handler, protocol: protocol, versions: versions.to_vec(), packet_count: packet_count, })?; Ok(()) }
identifier_body
service.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity 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 la...
else { Ok(()) } } /// Try to remove a reserved peer. pub fn remove_reserved_peer(&self, peer: &str) -> Result<(), NetworkError> { let host = self.host.read(); if let Some(ref host) = *host { host.remove_reserved_node(peer) } else { Ok(()) } } /// Set the non-reserved peer mode. pub fn set_no...
{ host.add_reserved_node(peer) }
conditional_block
cursor.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
isplay: &gdk::Display, cursor_type: gdk::CursorType) -> Option<Cursor> { let tmp = unsafe { ffi::gdk_cursor_new_for_display(display.unwrap_pointer(), cursor_type) }; if tmp.is_null() { None } else { Some(Cursor { pointer: tmp }) } ...
w_for_display(d
identifier_name
cursor.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
lse { Some(Cursor { pointer: tmp }) } } pub fn get_display(&self) -> Option<gdk::Display> { let tmp = unsafe { ffi::gdk_cursor_get_display(self.pointer) }; if tmp.is_null() { None } else { Some(gdk::Display::wrap_p...
None } e
conditional_block
cursor.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
/*pub fn get_image(&self) -> Option<gdk::Pixbuf> { let tmp = unsafe { ffi::gdk_cursor_get_image(self.pointer) }; if tmp.is_null() { None } else { Some(gdk::Pixbuf::wrap_pointer(tmp)) } }*/ pub fn get_cursor_type(&self) -> gdk::CursorType { un...
let tmp = unsafe { ffi::gdk_cursor_get_display(self.pointer) }; if tmp.is_null() { None } else { Some(gdk::Display::wrap_pointer(tmp)) } }
identifier_body
cursor.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
if tmp.is_null() { None } else { Some(Cursor { pointer: tmp }) } } /*pub fn new_from_pixbuf(display: &gdk::Display, pixbuf: &gdk::Pixbuf, x: i32, y: i32) -> Option<Cursor> { let tmp = unsafe { ffi::gdk_cursor_new_from_pixbuf(d...
let tmp = unsafe { ffi::gdk_cursor_new(cursor_type) };
random_line_split
quote-tokens.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// ignore-android // ignore-pretty: does not work well with `--test` #![feature(quote)] extern crate syntax; use syntax::ext::base::ExtCtxt; use syntax::ptr::P; fn syntax_extension(cx: &ExtCtxt) { let e_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, 1 + 2); let p_toks : Vec<syntax::ast::TokenTree> ...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
quote-tokens.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn main() { }
{ let e_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, 1 + 2); let p_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, (x, 1 .. 4, *)); let a: P<syntax::ast::Expr> = quote_expr!(cx, 1 + 2); let _b: Option<P<syntax::ast::Item>> = quote_item!(cx, static foo : int = $e_toks; ); let _c: P<...
identifier_body
quote-tokens.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(cx: &ExtCtxt) { let e_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, 1 + 2); let p_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, (x, 1.. 4, *)); let a: P<syntax::ast::Expr> = quote_expr!(cx, 1 + 2); let _b: Option<P<syntax::ast::Item>> = quote_item!(cx, static foo : int = $e_toks; ); ...
syntax_extension
identifier_name
freshen.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 fold_region(&mut self, r: ty::Region) -> ty::Region { match r { ty::ReEarlyBound(..) | ty::ReLateBound(..) => { // leave bound regions alone r } ty::ReStatic | ty::ReFree(_) | ty::ReScope(_) | ...
{ self.infcx.tcx }
identifier_body
freshen.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 self, t: Ty<'tcx>) -> Ty<'tcx> { if!ty::type_needs_infer(t) &&!ty::type_has_erasable_regions(t) { return t; } let tcx = self.infcx.tcx; match t.sty { ty::TyInfer(ty::TyVar(v)) => { self.freshen( self.infcx.type_variables...
fold_ty
identifier_name
freshen.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 ...
//! Note that you should be careful not to allow the output of freshening to leak to the user in //! error messages or in any other form. Freshening is only really useful as an internal detail. //! //! __An important detail concerning regions.__ The freshener also replaces *all* regions with //!'static. The reason behi...
random_line_split
lib.rs
//! Huffman //! //! A library for huffman coding written in Rust. //! extern crate bit_vec; mod encode; mod decode; use bit_vec::BitVec; use std::collections::HashMap; pub use encode::*; pub use decode::*; /// Alias for the type of frequency. pub type Frequency = usize; /// Alias for the hashmap pub type BinMap = H...
() { // "Hello" should yield: {'H': 1, 'e': 1, 'l': 2, 'o': 3} let message = b"Hello"; let freq_map = freq_analysis(message); assert_eq!(freq_map.len(), 4); assert_eq!(freq_map[&b'H'], 1); assert_eq!(freq_map[&b'e'], 1); assert_eq!(freq_map[&b'l'], 2); a...
test_freq_analysis
identifier_name
lib.rs
//! Huffman //! //! A library for huffman coding written in Rust. //! extern crate bit_vec; mod encode; mod decode; use bit_vec::BitVec; use std::collections::HashMap; pub use encode::*; pub use decode::*; /// Alias for the type of frequency. pub type Frequency = usize; /// Alias for the hashmap pub type BinMap = H...
assert_eq!(freq_map[&b'H'], 1); assert_eq!(freq_map[&b'e'], 1); assert_eq!(freq_map[&b'l'], 2); assert_eq!(freq_map[&b'o'], 1); } }
assert_eq!(freq_map.len(), 4);
random_line_split
lib.rs
//! Huffman //! //! A library for huffman coding written in Rust. //! extern crate bit_vec; mod encode; mod decode; use bit_vec::BitVec; use std::collections::HashMap; pub use encode::*; pub use decode::*; /// Alias for the type of frequency. pub type Frequency = usize; /// Alias for the hashmap pub type BinMap = H...
}
{ // "Hello" should yield: {'H': 1, 'e': 1, 'l': 2, 'o': 3} let message = b"Hello"; let freq_map = freq_analysis(message); assert_eq!(freq_map.len(), 4); assert_eq!(freq_map[&b'H'], 1); assert_eq!(freq_map[&b'e'], 1); assert_eq!(freq_map[&b'l'], 2); asse...
identifier_body
postings.rs
use docset::DocSet; /// Postings (also called inverted list) /// /// For a given term, it is the list of doc ids of the doc /// containing the term. Optionally, for each document, /// it may also give access to the term frequency /// as well as the list of term positions. /// /// Its main implementation is `SegmentPos...
/// Returns the positions offseted with a given value. /// The output vector will be resized to the `term_freq`. fn positions_with_offset(&mut self, offset: u32, output: &mut Vec<u32>); /// Returns the positions of the term in the given document. /// The output vector will be resized to the `term_...
/// Returns the term frequency fn term_freq(&self) -> u32;
random_line_split
postings.rs
use docset::DocSet; /// Postings (also called inverted list) /// /// For a given term, it is the list of doc ids of the doc /// containing the term. Optionally, for each document, /// it may also give access to the term frequency /// as well as the list of term positions. /// /// Its main implementation is `SegmentPos...
}
{ self.positions_with_offset(0u32, output); }
identifier_body
postings.rs
use docset::DocSet; /// Postings (also called inverted list) /// /// For a given term, it is the list of doc ids of the doc /// containing the term. Optionally, for each document, /// it may also give access to the term frequency /// as well as the list of term positions. /// /// Its main implementation is `SegmentPos...
(&mut self, output: &mut Vec<u32>) { self.positions_with_offset(0u32, output); } }
positions
identifier_name
attr-stmt-expr.rs
// Copyright 2018 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 ...
#[proc_macro_attribute] pub fn no_output(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); assert!(!item.to_string().is_empty()); "".parse().unwrap() }
{ assert!(attr.to_string().is_empty()); format!("{}, {}", item, item).parse().unwrap() }
identifier_body
attr-stmt-expr.rs
// Copyright 2018 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 ...
(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); assert_eq!(item.to_string(), "println!(\"{}\", string)"); item } #[proc_macro_attribute] pub fn duplicate(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); format...
expect_print_expr
identifier_name
attr-stmt-expr.rs
// Copyright 2018 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 expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string().is_empty()); assert_eq!(item.to_string(), "print_str(\"string\")"); item } #[proc_macro_attribute] pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream { assert!(attr.to_string()....
} #[proc_macro_attribute]
random_line_split
bitstring.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...
(value: &str) -> Self { let mut bits = Vec::new(); for b in value.chars() { bits.push(match b { '0' => Bit::Zero, '1' => Bit::One, _ => panic!("Could not extract bitstring from {}", value), }); } return Bitstring::create_from_bits(bits); } fn create_from_bits(bit...
create_from_string
identifier_name
bitstring.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...
} return Bitstring::create_from_bits(bits); } fn create_from_bits(bits: Vec<Bit>) -> Self { return Bitstring { bits: bits }; } pub fn bits(&self) -> &Vec<Bit> { &self.bits } pub fn len(&self) -> usize { self.bits().len() } pub fn bit(&self, i: usize) -> Bit { self.bits[i] } pub fn...
'0' => Bit::Zero, '1' => Bit::One, _ => panic!("Could not extract bitstring from {}", value), });
random_line_split
int.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
() { fn sum(args: &[TVMArgValue]) -> Result<TVMRetValue, Error> { let mut ret = 0i64; for arg in args.iter() { let val: i64 = arg.try_into()?; ret += val; } Ok(TVMRetValue::from(ret)) } tvm::function::register(sum, "mysum".to_owned(), false).unwrap();...
main
identifier_name
int.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
.unwrap(); assert_eq!(ret, 60); }
{ fn sum(args: &[TVMArgValue]) -> Result<TVMRetValue, Error> { let mut ret = 0i64; for arg in args.iter() { let val: i64 = arg.try_into()?; ret += val; } Ok(TVMRetValue::from(ret)) } tvm::function::register(sum, "mysum".to_owned(), false).unwrap(); ...
identifier_body
int.rs
/*
* or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. ...
* Licensed to the Apache Software Foundation (ASF) under one
random_line_split
whitespace.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #[test] fn test_trim_http_whitespace() { fn test_trim(in_: &[u8], out: &[u8])
test_trim(b"", b""); test_trim(b" ", b""); test_trim(b"a", b"a"); test_trim(b" a", b"a"); test_trim(b"a ", b"a"); test_trim(b" a ", b"a"); test_trim(b"\t", b""); test_trim(b"a", b"a"); test_trim(b"\ta", b"a"); test_trim(b"a\t", b"a"); test_trim(b"\ta\t", b"a"); }
{ let b = net_traits::trim_http_whitespace(in_); assert_eq!(b, out); }
identifier_body
whitespace.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #[test] fn test_trim_http_whitespace() { fn
(in_: &[u8], out: &[u8]) { let b = net_traits::trim_http_whitespace(in_); assert_eq!(b, out); } test_trim(b"", b""); test_trim(b" ", b""); test_trim(b"a", b"a"); test_trim(b" a", b"a"); test_trim(b"a ", b"a"); test_trim(b" a ", b"a"); test_trim(b"\t", b""); test_tr...
test_trim
identifier_name
whitespace.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #[test] fn test_trim_http_whitespace() { fn test_trim(in_: &[u8], out: &[u8]) { let b = net_traits::t...
test_trim(b" ", b""); test_trim(b"a", b"a"); test_trim(b" a", b"a"); test_trim(b"a ", b"a"); test_trim(b" a ", b"a"); test_trim(b"\t", b""); test_trim(b"a", b"a"); test_trim(b"\ta", b"a"); test_trim(b"a\t", b"a"); test_trim(b"\ta\t", b"a"); }
test_trim(b"", b"");
random_line_split
lib.rs
#![feature(entry_and_modify)] use std::collections::HashMap; use std::cmp::Ordering; const HEADER: &str = "Team | MP | W | D | L | P"; #[derive(Default, Eq, PartialEq)] struct Team { name: String, wins: u32, losses: u32, drawns: u32, matches: u32, } fn oposite(resul...
} impl PartialOrd for Team { fn partial_cmp(&self, other: &Team) -> Option<Ordering> { Some(self.cmp(other)) } } #[derive(Default)] struct ScoreTable<'a> { registry: HashMap<&'a str, Team>, } impl<'a> ScoreTable<'a> { pub fn record_match(&mut self, one_match: &'a str) { for row in on...
{ match other.points().cmp(&self.points()) { Ordering::Equal => self.name.partial_cmp(&other.name).unwrap(), other => other, } }
identifier_body
lib.rs
#![feature(entry_and_modify)] use std::collections::HashMap; use std::cmp::Ordering; const HEADER: &str = "Team | MP | W | D | L | P"; #[derive(Default, Eq, PartialEq)] struct Team { name: String, wins: u32, losses: u32, drawns: u32, matches: u32, } fn oposite(resul...
let header = String::from(HEADER); let summaries: String = ScoreTable::from(input) .teams() .iter() .map(|team| team.summary()) .collect::<Vec<_>>() .join("\n"); if summaries.is_empty() { return header; } header + "\n" + &summaries }
pub fn tally(input: &str) -> String {
random_line_split
lib.rs
#![feature(entry_and_modify)] use std::collections::HashMap; use std::cmp::Ordering; const HEADER: &str = "Team | MP | W | D | L | P"; #[derive(Default, Eq, PartialEq)] struct Team { name: String, wins: u32, losses: u32, drawns: u32, matches: u32, } fn oposite(resul...
(name: &str) -> Self { Self { name: String::from(name), wins: 0, losses: 0, drawns: 0, matches: 0, } } pub fn points(&self) -> u32 { self.wins * 3 + self.drawns } pub fn record_result(&mut self, result: &str) { ...
new
identifier_name
lib.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/. */ #![feature(append)] #![feature(arc_unique)] #![feature(ascii)] #![feature(as_slice)] #![feature(as_unsafe_cell)] #...
#![feature(plugin)] #![feature(ref_slice)] #![feature(rc_unique)] #![feature(slice_patterns)] #![feature(str_split_at)] #![feature(str_utf16)] #![feature(unicode)] #![feature(vec_push_all)] #![feature(slice_concat_ext)] #![deny(unsafe_code)] #![allow(non_snake_case)] #![doc = "The script crate contains all matters DO...
#![feature(hashmap_hasher)] #![feature(iter_arith)] #![feature(mpsc_select)] #![feature(nonzero)]
random_line_split
lib.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/. */ #![feature(append)] #![feature(arc_unique)] #![feature(ascii)] #![feature(as_slice)] #![feature(as_unsafe_cell)] #...
() {} #[allow(unsafe_code)] pub fn init() { unsafe { assert_eq!(js::jsapi::JS_Init(), 1); } // Create the global vtables used by the (generated) DOM // bindings to implement JS proxies. RegisterBindings::RegisterProxyHandlers(); perform_platform_specific_initialization(); }
perform_platform_specific_initialization
identifier_name
lib.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/. */ #![feature(append)] #![feature(arc_unique)] #![feature(ascii)] #![feature(as_slice)] #![feature(as_unsafe_cell)] #...
#[allow(unsafe_code)] pub fn init() { unsafe { assert_eq!(js::jsapi::JS_Init(), 1); } // Create the global vtables used by the (generated) DOM // bindings to implement JS proxies. RegisterBindings::RegisterProxyHandlers(); perform_platform_specific_initialization(); }
{}
identifier_body
util.rs
use math::{Vec2, Vec2f}; use types::{WadCoord, WadInfo, WadName, ChildId, WadNameCast}; #[derive(Copy, Clone)] pub enum WadType { Initial, Patch } const IWAD_HEADER: &'static [u8] = b"IWAD"; const PWAD_HEADER: &'static [u8] = b"PWAD"; pub fn wad_type_from_info(wad_info: &WadInfo) -> Option<WadType> { let id = &w...
Some(WadType::Initial) } else if id == PWAD_HEADER { Some(WadType::Patch) } else { None } } pub fn is_untextured(name: &WadName) -> bool { let bytes = name.as_bytes(); bytes[0] == b'-' && bytes[1] == 0 } pub fn is_sky_flat(name: &WadName) -> bool { name == &(&b"F_SKY1"[...
random_line_split
util.rs
use math::{Vec2, Vec2f}; use types::{WadCoord, WadInfo, WadName, ChildId, WadNameCast}; #[derive(Copy, Clone)] pub enum WadType { Initial, Patch } const IWAD_HEADER: &'static [u8] = b"IWAD"; const PWAD_HEADER: &'static [u8] = b"PWAD"; pub fn wad_type_from_info(wad_info: &WadInfo) -> Option<WadType> { let id = &w...
{ ((id & 0x7fff) as usize, id & 0x8000 != 0) }
identifier_body
util.rs
use math::{Vec2, Vec2f}; use types::{WadCoord, WadInfo, WadName, ChildId, WadNameCast}; #[derive(Copy, Clone)] pub enum WadType { Initial, Patch } const IWAD_HEADER: &'static [u8] = b"IWAD"; const PWAD_HEADER: &'static [u8] = b"PWAD"; pub fn wad_type_from_info(wad_info: &WadInfo) -> Option<WadType> { let id = &w...
else if id == PWAD_HEADER { Some(WadType::Patch) } else { None } } pub fn is_untextured(name: &WadName) -> bool { let bytes = name.as_bytes(); bytes[0] == b'-' && bytes[1] == 0 } pub fn is_sky_flat(name: &WadName) -> bool { name == &(&b"F_SKY1"[..]).to_wad_name() } pub fn from_wa...
{ Some(WadType::Initial) }
conditional_block
util.rs
use math::{Vec2, Vec2f}; use types::{WadCoord, WadInfo, WadName, ChildId, WadNameCast}; #[derive(Copy, Clone)] pub enum WadType { Initial, Patch } const IWAD_HEADER: &'static [u8] = b"IWAD"; const PWAD_HEADER: &'static [u8] = b"PWAD"; pub fn
(wad_info: &WadInfo) -> Option<WadType> { let id = &wad_info.identifier; if id == IWAD_HEADER { Some(WadType::Initial) } else if id == PWAD_HEADER { Some(WadType::Patch) } else { None } } pub fn is_untextured(name: &WadName) -> bool { let bytes = name.as_bytes(); byt...
wad_type_from_info
identifier_name
network.rs
use std::collections::HashMap; use std::sync::mpsc::{Receiver, SyncSender}; use std::net::UdpSocket; use processor::{InputProcessor, ConfigurableFilter}; /// # Network input /// /// - listens on an UDP port for data, forward upstream /// /// ### catapult.conf /// /// ``` /// input { /// network { /// listenPort ...
(&self) -> Vec<&str> { vec!["listenPort"] } } impl InputProcessor for Network { fn start(&self, config: &Option<HashMap<String,String>>) -> Receiver<String> { self.requires_fields(config, self.mandatory_fields()); self.invoke(config, Network::handle_func) } fn handle_func(tx: SyncSender<String>, o...
mandatory_fields
identifier_name
network.rs
use std::collections::HashMap; use std::sync::mpsc::{Receiver, SyncSender}; use std::net::UdpSocket; use processor::{InputProcessor, ConfigurableFilter}; /// # Network input /// /// - listens on an UDP port for data, forward upstream /// /// ### catapult.conf /// /// ``` /// input { /// network { /// listenPort ...
} } } }
{ println!("Unable to send line to processor: {}", e); println!("{}", ll) }
conditional_block
network.rs
use std::collections::HashMap; use std::sync::mpsc::{Receiver, SyncSender}; use std::net::UdpSocket; use processor::{InputProcessor, ConfigurableFilter}; /// # Network input ///
/// /// ``` /// input { /// network { /// listenPort = 6667 /// } /// } /// ``` /// ### Parameters /// /// - **listenPort**: UDP port to listen to pub struct Network { name: String } impl Network { pub fn new(name: String) -> Network { Network{ name: name } } } impl ConfigurableFilter for Network ...
/// - listens on an UDP port for data, forward upstream /// /// ### catapult.conf
random_line_split
simctrl.rs
// use mio; // use mio::{ Handler }; // use std::cell::RefCell; // use std::rc::Rc; // pub trait Update : Handler { // fn update(&mut self); // fn run(&mut self, timeout : Self::Timeout, delay : u64) { // let mut ev_cfg = mio::EventLoopConfig::new(); // ev_cfg.timer_tick_ms(10); // let m...
pub const ZONG_SHU_JI_ZU_QI_LUN : usize = 4; pub const ZONG_SHU_AN_DIAN : usize = 4; pub const ZONG_SHU_NODE : usize = 23; pub const ZONG_SHU_ZHI_LU : usize = 25; pub const ZONG_SHU_FU_ZAI : usize = 21; pub const ZONG_SHU_DUAN_LU_QI : usize = 38; // pub const ZONG_SHU_SHOU_TI_DUI_JI_ZU : usize = 0; // pub const ZONG_SH...
pub const ZONG_SHU_JI_ZU : usize = 13; pub const ZONG_SHU_JI_ZU_CHAI_YOU : usize = 5;
random_line_split
simctrl.rs
// use mio; // use mio::{ Handler }; // use std::cell::RefCell; // use std::rc::Rc; // pub trait Update : Handler { // fn update(&mut self); // fn run(&mut self, timeout : Self::Timeout, delay : u64) { // let mut ev_cfg = mio::EventLoopConfig::new(); // ev_cfg.timer_tick_ms(10); // let m...
, Wu, } #[derive(PartialEq, Copy, Clone, Debug, Serialize, Deserialize)] pub enum ZhanWeiType{ JiPang, ZhuKongZhiPing, JiZuKongZhiQi, DianZhanKongZhiQi, DianZhanJianKongTai, JiKongTai, BeiYongJiKongTai, JiaoLian, Admin, Internal, Wu, } #[derive(PartialEq, Copy, Clone, D...
ZhiLu
identifier_name
seg_queue.rs
use std::sync::atomic::Ordering::{Acquire, Release, Relaxed}; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::fmt; use std::{ptr, mem}; use std::cmp; use std::cell::UnsafeCell; use mem::epoch::{self, Atomic, Owned}; const SEG_SIZE: usize = 32; /// A Michael-Scott queue that allocates "segments" (arrays of...
} if head.next.load(Relaxed, &guard).is_none() { return None } } } } #[cfg(test)] mod test { const CONC_COUNT: i64 = 1000000; use scope; use super::*; #[test] fn push_pop_1() { let q: SegQueue<i64> = SegQueue::new(); q.push(37); assert_...
{ unsafe { let cell = (*head).data.get_unchecked(low).get(); loop { if (*cell).1.load(Acquire) { break } } if low + 1 == SEG_SIZE { loop { ...
conditional_block
seg_queue.rs
use std::sync::atomic::Ordering::{Acquire, Release, Relaxed}; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::fmt; use std::{ptr, mem}; use std::cmp; use std::cell::UnsafeCell; use mem::epoch::{self, Atomic, Owned}; const SEG_SIZE: usize = 32; /// A Michael-Scott queue that allocates "segments" (arrays of...
let guard = epoch::pin(); loop { let head = self.head.load(Acquire, &guard).unwrap(); loop { let low = head.low.load(Relaxed); if low >= cmp::min(head.high.load(Relaxed), SEG_SIZE) { break } if head.low.compare_and_swap(low, low+1, ...
pub fn try_pop(&self) -> Option<T> {
random_line_split
seg_queue.rs
use std::sync::atomic::Ordering::{Acquire, Release, Relaxed}; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::fmt; use std::{ptr, mem}; use std::cmp; use std::cell::UnsafeCell; use mem::epoch::{self, Atomic, Owned}; const SEG_SIZE: usize = 32; /// A Michael-Scott queue that allocates "segments" (arrays of...
() { let q: SegQueue<i64> = SegQueue::new(); scope(|scope| { scope.spawn(|| { let mut next = 0; while next < CONC_COUNT { if let Some(elem) = q.try_pop() { assert_eq!(elem, next); next += 1;...
push_pop_many_spsc
identifier_name
stack.rs
// This file is part of libfringe, a low-level green threading library. // Copyright (c) whitequark <whitequark@whitequark.org> // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at y...
#[test] fn owned_stack() { let stack = OwnedStack::new(1024); assert_eq!(stack.base() as usize & (STACK_ALIGNMENT - 1), 0); assert_eq!(stack.limit() as usize & (STACK_ALIGNMENT - 1), 0); assert_eq!(stack.base() as usize - stack.limit() as usize, 1024); } #[test] fn default_os_stack() { let stack = OsStack::...
random_line_split
stack.rs
// This file is part of libfringe, a low-level green threading library. // Copyright (c) whitequark <whitequark@whitequark.org> // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at y...
#[test] fn default_os_stack() { let stack = OsStack::new(0).unwrap(); assert_eq!(stack.base() as usize & (STACK_ALIGNMENT - 1), 0); assert_eq!(stack.limit() as usize & (STACK_ALIGNMENT - 1), 0); // Make sure the topmost page of the stack, at least, is accessible. unsafe { *(stack.base().offset(-1)) = 0; } ...
{ let stack = OwnedStack::new(1024); assert_eq!(stack.base() as usize & (STACK_ALIGNMENT - 1), 0); assert_eq!(stack.limit() as usize & (STACK_ALIGNMENT - 1), 0); assert_eq!(stack.base() as usize - stack.limit() as usize, 1024); }
identifier_body
stack.rs
// This file is part of libfringe, a low-level green threading library. // Copyright (c) whitequark <whitequark@whitequark.org> // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at y...
() { unsafe { let ptr = heap::allocate(16384, STACK_ALIGNMENT); let mut slice = Box::from_raw(slice::from_raw_parts_mut(ptr, 16384)); let stack = SliceStack::new(&mut slice[4096..8192]); assert_eq!(stack.base() as usize & (STACK_ALIGNMENT - 1), 0); assert_eq!(stack.limit() as usize & (STACK_ALIGNM...
slice_aligned
identifier_name
perf.rs
use crate::vm::{Code, VM}; use dora_parser::interner::Name; #[cfg(target_os = "linux")] pub fn
(code: &Code, vm: &VM, name: Name) { use std::fs::OpenOptions; use std::io::prelude::*; let pid = unsafe { libc::getpid() }; let fname = format!("/tmp/perf-{}.map", pid); let mut options = OpenOptions::new(); let mut file = options.create(true).append(true).open(&fname).unwrap(); let code...
register_with_perf
identifier_name
perf.rs
use crate::vm::{Code, VM}; use dora_parser::interner::Name; #[cfg(target_os = "linux")] pub fn register_with_perf(code: &Code, vm: &VM, name: Name) { use std::fs::OpenOptions; use std::io::prelude::*; let pid = unsafe { libc::getpid() }; let fname = format!("/tmp/perf-{}.map", pid);
let code_end = code.instruction_end().to_usize(); let name = vm.interner.str(name); let line = format!( "{:x} {:x} dora::{}\n", code_start, code_end - code_start, name ); file.write_all(line.as_bytes()).unwrap(); } #[cfg(not(target_os = "linux"))] pub fn register_wi...
let mut options = OpenOptions::new(); let mut file = options.create(true).append(true).open(&fname).unwrap(); let code_start = code.instruction_start().to_usize();
random_line_split
perf.rs
use crate::vm::{Code, VM}; use dora_parser::interner::Name; #[cfg(target_os = "linux")] pub fn register_with_perf(code: &Code, vm: &VM, name: Name) { use std::fs::OpenOptions; use std::io::prelude::*; let pid = unsafe { libc::getpid() }; let fname = format!("/tmp/perf-{}.map", pid); let mut optio...
{ // nothing to do }
identifier_body
vec.rs
#[no_std]; #[no_core]; use zero; pub trait OwnedVector<T> { unsafe fn push_fast(&mut self, t: T); unsafe fn len(&self) -> uint; unsafe fn set_len(&mut self, newlen: uint); unsafe fn as_mut_buf<U>(&self, f: &fn(*mut T, uint) -> U) -> U; unsafe fn data(&self) -> *u8; } pub struct Vec<T> { fill:...
(&mut self, t: T) { let repr: **mut Vec<u8> = zero::transmute(self); let fill = (**repr).fill; (**repr).fill += zero::size_of::<T>(); let p = &(**repr).data as *u8 as uint; let mut i = 0; while i < zero::size_of::<T>() { *((p+fill+i) as *mut u8) = *((&t as *T...
push_fast
identifier_name
vec.rs
#[no_std]; #[no_core]; use zero; pub trait OwnedVector<T> { unsafe fn push_fast(&mut self, t: T); unsafe fn len(&self) -> uint; unsafe fn set_len(&mut self, newlen: uint); unsafe fn as_mut_buf<U>(&self, f: &fn(*mut T, uint) -> U) -> U; unsafe fn data(&self) -> *u8; } pub struct Vec<T> { fill:...
let fill = (**repr).fill; (**repr).fill += zero::size_of::<T>(); let p = &(**repr).data as *u8 as uint; let mut i = 0; while i < zero::size_of::<T>() { *((p+fill+i) as *mut u8) = *((&t as *T as uint + i) as *mut u8); i += 1; } } unsafe fn...
#[inline] unsafe fn push_fast(&mut self, t: T) { let repr: **mut Vec<u8> = zero::transmute(self);
random_line_split
vec.rs
#[no_std]; #[no_core]; use zero; pub trait OwnedVector<T> { unsafe fn push_fast(&mut self, t: T); unsafe fn len(&self) -> uint; unsafe fn set_len(&mut self, newlen: uint); unsafe fn as_mut_buf<U>(&self, f: &fn(*mut T, uint) -> U) -> U; unsafe fn data(&self) -> *u8; } pub struct Vec<T> { fill:...
}
{ let repr: **mut Vec<u8> = zero::transmute(self); &(**repr).data as *u8 }
identifier_body
dsp.rs
//! Emulates the DSP used in the APU. #![allow(dead_code)] // FIXME Implement the DSP #[derive(Copy, Clone, Default)] struct Voice { // Registers /// $x0 - Left channel volume lvol: i8, /// $x1 - Right channel volume rvol: i8, /// $x2 (low)/x3 (high) (14 bit) pitch: u16, /// $x4 -...
{ /// Continue playing with the next BRR block Continue, /// Jump to the block's loop address and set the ENDx flag for this voice Loop, /// Jump to the loop address, set ENDx, enter `Release`, set env to $000 Release, } struct BrrBlock { /// 0-12 where 0 = silent and 12 = loudest shif...
BrrLoop
identifier_name
dsp.rs
//! Emulates the DSP used in the APU. #![allow(dead_code)] // FIXME Implement the DSP #[derive(Copy, Clone, Default)] struct Voice { // Registers /// $x0 - Left channel volume lvol: i8, /// $x1 - Right channel volume rvol: i8, /// $x2 (low)/x3 (high) (14 bit) pitch: u16, /// $x4 -...
match reg & 0x0f { 0x00 => voice.lvol as u8, 0x01 => voice.rvol as u8, 0x02 => voice.pitch as u8, 0x03 => (voice.pitch >> 8) as u8, 0x04 => voice.source, 0x05 => voice.adsr1, ...
{ reg &= 0x7f; match reg { 0x0c => self.lmvol, 0x1c => self.rmvol, 0x2c => self.levol, 0x3c => self.revol, 0x4c => self.keyon, 0x5c => self.keyoff, 0x6c => self.flags, 0x7c => self.endx, 0x0d => s...
identifier_body
dsp.rs
//! Emulates the DSP used in the APU. #![allow(dead_code)] // FIXME Implement the DSP #[derive(Copy, Clone, Default)] struct Voice { // Registers /// $x0 - Left channel volume lvol: i8, /// $x1 - Right channel volume rvol: i8, /// $x2 (low)/x3 (high) (14 bit) pitch: u16, /// $x4 -...
0x4c => self.keyon = value, 0x5c => self.keyoff = value, 0x6c => self.flags = value, 0x7c => self.endx = value, 0x0d => self.efb = value, 0x2d => self.pmod = value, 0x3d => self.noise = value, 0x4d => self.echo = value, ...
0x1c => self.rmvol = value, 0x2c => self.levol = value, 0x3c => self.revol = value,
random_line_split
template.rs
/* Example demonstrating Sending a Secure Message. */ // ------------------------------------------ // crates.io // ------------------------------------------ #[macro_use] extern crate serde_json; // ------------------------------------------ // hyperledger crates // ------------------------------------------ exter...
fn prep(wallet_handle: i32, sender_vk: &str, receipt_vk: &str) { let mut file = File::create(FILE).unwrap(); println!("Enter message"); let mut message = String::new(); io::stdin().read_line(&mut message).unwrap(); let encrypted_msg = crypto::auth_crypt(wallet_handle, &sender_vk, &receipt_vk, me...
{ let mut cmd = String::new(); println!("Who are you? "); io::stdin().read_line(&mut cmd).unwrap(); let config = json!({ "id" : format!("{}-wallet", cmd) }).to_string(); wallet::create_wallet(&config, USEFUL_CREDENTIALS).wait().unwrap(); let wallet_handle: i32 = wallet::open_wallet(&config, US...
identifier_body
template.rs
/* Example demonstrating Sending a Secure Message. */ // ------------------------------------------ // crates.io // ------------------------------------------ #[macro_use] extern crate serde_json; // ------------------------------------------ // hyperledger crates // ------------------------------------------ exter...
file.write_all(&encrypted_msg).unwrap(); } fn read(wallet_handle: i32, receipt_vk: &str) { let mut file = File::open(FILE).unwrap(); let mut contents = Vec::new(); file.read_to_end(&mut contents).unwrap(); let (sender, decrypted_msg) = crypto::auth_decrypt(wallet_handle, &receipt_vk, &contents).w...
random_line_split
template.rs
/* Example demonstrating Sending a Secure Message. */ // ------------------------------------------ // crates.io // ------------------------------------------ #[macro_use] extern crate serde_json; // ------------------------------------------ // hyperledger crates // ------------------------------------------ exter...
() { let (wallet_handle, verkey, other_verkey) = init(); loop { println!("ToDo"); let mut cmd = String::new(); io::stdin().read_line(&mut cmd).unwrap(); cmd = cmd.trim().to_string(); if cmd == "prep" { prep(wallet_handle, &verkey, &other_verkey); } ...
main
identifier_name
utils.rs
str::DOMString; use dom::bindings::trace::trace_object; use dom::browsingcontext; use heapsize::HeapSizeOf; use js; use js::JS_CALLEE; use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper}; use js::glue::{GetCrossCompartmentWrapper, WrapperNew}; use js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO, RUST...
} let property = CString::new(property).unwrap(); if object.get().is_null() { return Ok(false); } let mut found = false; if!has_property(cx, object, &property, &mut found) { return Err(()); } if!found { return Ok(false); } if!get_property(cx, object, &...
object: HandleObject, property: &CString, value: MutableHandleValue) -> bool { unsafe { JS_GetProperty(cx, object, property.as_ptr(), value) }
random_line_split
utils.rs
DOMString; use dom::bindings::trace::trace_object; use dom::browsingcontext; use heapsize::HeapSizeOf; use js; use js::JS_CALLEE; use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper}; use js::glue::{GetCrossCompartmentWrapper, WrapperNew}; use js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO, RUST_JSID...
(cx: *mut JSContext, object: HandleObject, property: &str, rval: MutableHandleValue) -> Result<bool, ()> { fn has_property(cx: *mut JSContext, object: HandleObject, ...
get_dictionary_property
identifier_name
utils.rs
DOMString; use dom::bindings::trace::trace_object; use dom::browsingcontext; use heapsize::HeapSizeOf; use js; use js::JS_CALLEE; use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper}; use js::glue::{GetCrossCompartmentWrapper, WrapperNew}; use js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO, RUST_JSID...
assert!(!ptr.is_null()); let bytes = slice::from_raw_parts(ptr, length as usize); if let Some(init_fun) = InterfaceObjectMap::MAP.get(bytes) { init_fun(cx, obj); *rval = true; } else { *rval = false; } true } unsafe extern "C" fn wrap(cx: *mut JSContext, ...
{ assert!(JS_IsGlobalObject(obj.get())); if !JS_ResolveStandardClass(cx, obj, id, rval) { return false; } if *rval { return true; } if !RUST_JSID_IS_STRING(id) { *rval = false; return true; } let string = RUST_JSID_TO_STRING(id); if !JS_StringHasLatin...
identifier_body
utils.rs
DOMString; use dom::bindings::trace::trace_object; use dom::browsingcontext; use heapsize::HeapSizeOf; use js; use js::JS_CALLEE; use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper}; use js::glue::{GetCrossCompartmentWrapper, WrapperNew}; use js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO, RUST_JSID...
} Ok(()) } /// Returns whether `proxy` has a property `id` on its prototype. pub unsafe fn has_property_on_prototype(cx: *mut JSContext, proxy: HandleObject, id: HandleId, found: &mut bool)...
{ return Err(()); }
conditional_block
issue_16723_multiple_items_syntax_ext.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 ...
{ MacItems::new(vec![ quote_item!(cx, struct Struct1;).unwrap(), quote_item!(cx, struct Struct2;).unwrap() ].into_iter()) }
identifier_body
issue_16723_multiple_items_syntax_ext.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
// ignore-stage1 // force-host #![feature(plugin_registrar, quote)] #![crate_type = "dylib"] extern crate syntax; extern crate rustc; use syntax::ast; use syntax::codemap; use syntax::ext::base::{ExtCtxt, MacResult, MacItems}; use rustc::plugin::Registry; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Regis...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
issue_16723_multiple_items_syntax_ext.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 ...
(reg: &mut Registry) { reg.register_macro("multiple_items", expand) } fn expand(cx: &mut ExtCtxt, _: codemap::Span, _: &[ast::TokenTree]) -> Box<MacResult+'static> { MacItems::new(vec![ quote_item!(cx, struct Struct1;).unwrap(), quote_item!(cx, struct Struct2;).unwrap() ].into_iter()) }
plugin_registrar
identifier_name
test-ignore-cfg.rs
// 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. // compile-flags: -...
// 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. //
random_line_split
test-ignore-cfg.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 ...
#[test] fn checktests() { // Pull the tests out of the secreturn test module let tests = __test::tests; assert!(vec::any( tests, |t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore)); assert!(vec::any( tests, |t| t.desc.name.to_str() == ~"shouldnotignore" &&!...
{ }
identifier_body
test-ignore-cfg.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 ...
() { // Pull the tests out of the secreturn test module let tests = __test::tests; assert!(vec::any( tests, |t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore)); assert!(vec::any( tests, |t| t.desc.name.to_str() == ~"shouldnotignore" &&!t.desc.ignore)); }
checktests
identifier_name
mod.rs
#[macro_use] pub mod macros; pub mod reg; pub mod mmu; pub mod semihosting; use core::ops::Drop; pub fn local_irqs_disable() { unsafe { asm!("msr daifset, #2" : : : "cc", "memory" : "volatile") } } pub fn
() { unsafe { asm!("msr daifclr, #2" : : : "cc", "memory" : "volatile") } } fn cpu_flags_read() -> u64 { reg::daif::read() } fn cpu_flags_write(flag : u64) { reg::daif::write(flag); } pub struct CriticalSectionGuard { flags : u64, } im...
local_irqs_enable
identifier_name
mod.rs
#[macro_use] pub mod macros; pub mod reg; pub mod mmu; pub mod semihosting; use core::ops::Drop; pub fn local_irqs_disable() { unsafe { asm!("msr daifset, #2" : : : "cc", "memory" : "volatile") } } pub fn local_irqs_enable() { unsafe { a...
fn cpu_flags_write(flag : u64) { reg::daif::write(flag); } pub struct CriticalSectionGuard { flags : u64, } impl Drop for CriticalSectionGuard { fn drop(&mut self) { cpu_flags_write(self.flags); } } pub fn critical_section_start() -> CriticalSectionGuard { let ret = CriticalSectionGuar...
{ reg::daif::read() }
identifier_body
mod.rs
pub mod semihosting; use core::ops::Drop; pub fn local_irqs_disable() { unsafe { asm!("msr daifset, #2" : : : "cc", "memory" : "volatile") } } pub fn local_irqs_enable() { unsafe { asm!("msr daifclr, #2" : : ...
#[macro_use] pub mod macros; pub mod reg; pub mod mmu;
random_line_split
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #[macro_use] mod macros; mod error; pub use error::{Error, Result, WaitForTransactionError}; cfg_blocking! { mod blocking; pub use blocking::BlockingClient; } cfg_async! { mod client; pub use client::Client; } mod re...
{ #[serde(rename = "2.0")] V2, } #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] pub enum Method { Submit, GetMetadata, GetAccount, GetTransactions, GetAccountTransaction, GetAccountTransactions, GetEvents, GetCurrencies, GetNetworkStatus, ...
JsonRpcVersion
identifier_name
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #[macro_use] mod macros; mod error; pub use error::{Error, Result, WaitForTransactionError}; cfg_blocking! { mod blocking; pub use blocking::BlockingClient; } cfg_async! { mod client; pub use client::Client; } mod re...
V2, } #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] pub enum Method { Submit, GetMetadata, GetAccount, GetTransactions, GetAccountTransaction, GetAccountTransactions, GetEvents, GetCurrencies, GetNetworkStatus, // // Experimental APIs ...
random_line_split
dependency_graph.rs
//! Functions related to working with dependency graphs //! //! For example, given a set of maybe recursive functions, you want //! to order them such that the type signatures can be determined completely. //! If you put mutually recursive functions together in groups, these groups //! can then be placed in a DAG of de...
.ids() .flat_map(|member| &siblings_out_refs[member]) .filter(|out_ref|!group.contains(out_ref)) .map(|out_ref| { groups .iter() .find(|&(_, ref group2)| group2.contains(out_ref)) .map(|(n, _)| *n) .unwrap() }) ...
random_line_split
dependency_graph.rs
//! Functions related to working with dependency graphs //! //! For example, given a set of maybe recursive functions, you want //! to order them such that the type signatures can be determined completely. //! If you put mutually recursive functions together in groups, these groups //! can then be placed in a DAG of de...
<'src>( start: &'src str, current: &'src str, siblings_out_refs: &BTreeMap<&str, BTreeSet<&'src str>>, visited: &mut BTreeSet<&'src str>, ) -> BTreeSet<&'src str> { if current == start && visited.contains(current) { once(current).collect() } else if visited.contains(current) { BT...
circular_def_members_
identifier_name
dependency_graph.rs
//! Functions related to working with dependency graphs //! //! For example, given a set of maybe recursive functions, you want //! to order them such that the type signatures can be determined completely. //! If you put mutually recursive functions together in groups, these groups //! can then be placed in a DAG of de...
refs } Let(ref l) => { let shadoweds = l.bindings .ids() .filter_map(|id| if siblings.remove(id) { Some(id) } else { None }) .collect::<Vec<_>>(); let refs = l.bindings .bindings() .map(|b| &b...
{ siblings.insert(l.param_ident.s); }
conditional_block