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
mod.rs
//! Implementation of mio for Windows using IOCP //! //! This module uses I/O Completion Ports (IOCP) on Windows to implement mio's //! Unix epoll-like interface. Unfortunately these two I/O models are //! fundamentally incompatible: //! //! * IOCP is a completion-based model where work is submitted to the kernel and /...
(handle: winapi::HANDLE) -> io::Result<()> { // TODO: move those to winapi const FILE_SKIP_COMPLETION_PORT_ON_SUCCESS: winapi::UCHAR = 1; const FILE_SKIP_SET_EVENT_ON_HANDLE: winapi::UCHAR = 2; let flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS | FILE_SKIP_SET_EVENT_ON_HANDLE; let r = kernel32::SetF...
no_notify_on_instant_completion
identifier_name
mod.rs
//! Implementation of mio for Windows using IOCP //! //! This module uses I/O Completion Ports (IOCP) on Windows to implement mio's //! Unix epoll-like interface. Unfortunately these two I/O models are //! fundamentally incompatible: //! //! * IOCP is a completion-based model where work is submitted to the kernel and /...
io::Error::new(io::ErrorKind::WouldBlock, "operation would block") } unsafe fn cancel(socket: &AsRawSocket, overlapped: &Overlapped) -> io::Result<()> { let handle = socket.as_raw_socket() as winapi::HANDLE; let ret = kernel32::CancelIoEx(handle, overlapped.as_mut_ptr()); if ret == 0 {...
fn wouldblock() -> io::Error {
random_line_split
mod.rs
//! Implementation of mio for Windows using IOCP //! //! This module uses I/O Completion Ports (IOCP) on Windows to implement mio's //! Unix epoll-like interface. Unfortunately these two I/O models are //! fundamentally incompatible: //! //! * IOCP is a completion-based model where work is submitted to the kernel and /...
{ // TODO: move those to winapi const FILE_SKIP_COMPLETION_PORT_ON_SUCCESS: winapi::UCHAR = 1; const FILE_SKIP_SET_EVENT_ON_HANDLE: winapi::UCHAR = 2; let flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS | FILE_SKIP_SET_EVENT_ON_HANDLE; let r = kernel32::SetFileCompletionNotificationModes(handle, flag...
identifier_body
args.rs
// Copyright (c) 2018 Jason White // // 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, modify, merge, publish, d...
); assert_eq!(format!("{}", Arg::new(r"C:\foo\bar")), r"C:\foo\bar"); assert_eq!(format!("{}", Arg::new(r"\\foo\bar")), r"\\foo\bar"); } #[test] #[cfg(unix)] fn test_arg_display() { assert_eq!(format!("{}", Arg::new("foo bar")), "\"foo bar\""); assert_eq!(format!...
random_line_split
args.rs
// Copyright (c) 2018 Jason White // // 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, modify, merge, publish, d...
/// Generates a temporary response file for the list of arguments. pub fn response_file(&self) -> io::Result<TempPath> { let tempfile = NamedTempFile::new()?; { let mut writer = io::BufWriter::new(&tempfile); // Write UTF-8 BOM. Some tools require this to properly dec...
{ #[cfg(windows)] { self.byte_count() > 32768 } #[cfg(unix)] { self.byte_count() > 0x20000 } }
identifier_body
args.rs
// Copyright (c) 2018 Jason White // // 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, modify, merge, publish, d...
Ok(()) } /// Quotes the argument such that it is safe to pass to the shell. #[cfg(unix)] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let quote = self.0.chars().any(|c| " \n\t#<>'&|".contains(c)) || self.0.is_empty(); if quote { f.write_c...
{ // Escape any trailing backslashes. for _ in 0..backslashes { f.write_char('\\')?; } f.write_char('"')?; }
conditional_block
args.rs
// Copyright (c) 2018 Jason White // // 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, modify, merge, publish, d...
(s: &'a str) -> ArgBuf { ArgBuf::from(s.to_string()) } } impl ops::Deref for ArgBuf { type Target = Arg; fn deref(&self) -> &Self::Target { &Arg::new(&self.0) } } impl AsRef<Arg> for ArgBuf { fn as_ref(&self) -> &Arg { self } } impl AsRef<OsStr> for ArgBuf { fn as...
from
identifier_name
vrframedata.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::VRFrameDataBinding; use crate::dom::bindings::codegen::Bindings::VRF...
#[dom_struct] pub struct VRFrameData { reflector_: Reflector, left_proj: Heap<*mut JSObject>, left_view: Heap<*mut JSObject>, right_proj: Heap<*mut JSObject>, right_view: Heap<*mut JSObject>, pose: Dom<VRPose>, timestamp: Cell<f64>, first_timestamp: Cell<f64>, } impl VRFrameData { ...
random_line_split
vrframedata.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::VRFrameDataBinding; use crate::dom::bindings::codegen::Bindings::VRF...
} } impl VRFrameDataMethods for VRFrameData { // https://w3c.github.io/webvr/#dom-vrframedata-timestamp fn Timestamp(&self) -> Finite<f64> { Finite::wrap(self.timestamp.get() - self.first_timestamp.get()) } #[allow(unsafe_code)] // https://w3c.github.io/webvr/#dom-vrframedata-leftproj...
{ self.first_timestamp.set(data.timestamp); }
conditional_block
vrframedata.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::VRFrameDataBinding; use crate::dom::bindings::codegen::Bindings::VRF...
{ reflector_: Reflector, left_proj: Heap<*mut JSObject>, left_view: Heap<*mut JSObject>, right_proj: Heap<*mut JSObject>, right_view: Heap<*mut JSObject>, pose: Dom<VRPose>, timestamp: Cell<f64>, first_timestamp: Cell<f64>, } impl VRFrameData { fn new_inherited(pose: &VRPose) -> VR...
VRFrameData
identifier_name
vrframedata.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::VRFrameDataBinding; use crate::dom::bindings::codegen::Bindings::VRF...
#[allow(unsafe_code)] // https://w3c.github.io/webvr/#dom-vrframedata-leftprojectionmatrix unsafe fn LeftProjectionMatrix(&self, _cx: *mut JSContext) -> NonNull<JSObject> { NonNull::new_unchecked(self.left_proj.get()) } #[allow(unsafe_code)] // https://w3c.github.io/webvr/#dom-vrframe...
{ Finite::wrap(self.timestamp.get() - self.first_timestamp.get()) }
identifier_body
wincon.rs
// Copyright © 2015, Peter Atashian // Licensed under the MIT License <LICENSE.md> //! This module contains the public data structures, data types, and procedures exported by the NT //! console subsystem. STRUCT!{struct COORD { X: ::SHORT, Y: ::SHORT, }} pub type PCOORD = *mut COORD; STRUCT!{struct SMALL_RECT {...
pub const CONSOLE_REAL_OUTPUT_HANDLE: *mut ::c_void = -2isize as *mut ::c_void; pub const CONSOLE_REAL_INPUT_HANDLE: *mut ::c_void = -3isize as *mut ::c_void; pub const ATTACH_PARENT_PROCESS: ::DWORD = 0xFFFFFFFF; STRUCT!{struct CONSOLE_READCONSOLE_CONTROL { nLength: ::ULONG, nInitialChars: ::ULONG, dwCtrlW...
pub const ENABLE_EXTENDED_FLAGS: ::DWORD = 0x0080; pub const ENABLE_AUTO_POSITION: ::DWORD = 0x0100; pub const ENABLE_PROCESSED_OUTPUT: ::DWORD = 0x0001; pub const ENABLE_WRAP_AT_EOL_OUTPUT: ::DWORD = 0x0002;
random_line_split
predict.rs
#[macro_use] extern crate log; extern crate fern; extern crate time; extern crate gpredict; use gpredict::{Predict, Location, Tle}; use std::thread; fn conf_logger()
fn main() { // setup fern logger conf_logger(); // start processing info!("predict example started"); let tle: Tle = Tle { name: "GRIFEX".to_string(), line1: "1 40379U 15003D 15243.42702278 .00003367 00000-0 17130-3 0 9993".to_string(), line2: "2 40379 99.1124 290.6...
{ let logger_config = fern::DispatchConfig { format: Box::new(|msg: &str, level: &log::LogLevel, _location: &log::LogLocation| { let t = time::now(); let ms = t.tm_nsec/1000_000; format!("{}.{:3} [{}] {}", t.strftime("%Y-%m-%dT%H:%M:%S").unwrap(), ms, level, msg) ...
identifier_body
predict.rs
#[macro_use] extern crate log; extern crate fern; extern crate time; extern crate gpredict; use gpredict::{Predict, Location, Tle}; use std::thread; fn conf_logger() { let logger_config = fern::DispatchConfig { format: Box::new(|msg: &str, level: &log::LogLevel, _location: &log::LogLocation| { ...
} fn main() { // setup fern logger conf_logger(); // start processing info!("predict example started"); let tle: Tle = Tle { name: "GRIFEX".to_string(), line1: "1 40379U 15003D 15243.42702278 .00003367 00000-0 17130-3 0 9993".to_string(), line2: "2 40379 99.1124 290...
{ panic!("Failed to initialize global logger: {}", e); }
conditional_block
predict.rs
#[macro_use] extern crate log; extern crate fern; extern crate time; extern crate gpredict; use gpredict::{Predict, Location, Tle}; use std::thread; fn conf_logger() { let logger_config = fern::DispatchConfig { format: Box::new(|msg: &str, level: &log::LogLevel, _location: &log::LogLocation| { ...
level: log::LogLevelFilter::Trace, }; if let Err(e) = fern::init_global_logger(logger_config, log::LogLevelFilter::Trace) { panic!("Failed to initialize global logger: {}", e); } } fn main() { // setup fern logger conf_logger(); // start processing info!("predict example s...
let ms = t.tm_nsec/1000_000; format!("{}.{:3} [{}] {}", t.strftime("%Y-%m-%dT%H:%M:%S").unwrap(), ms, level, msg) }), output: vec![fern::OutputConfig::stderr()],
random_line_split
predict.rs
#[macro_use] extern crate log; extern crate fern; extern crate time; extern crate gpredict; use gpredict::{Predict, Location, Tle}; use std::thread; fn conf_logger() { let logger_config = fern::DispatchConfig { format: Box::new(|msg: &str, level: &log::LogLevel, _location: &log::LogLocation| { ...
() { // setup fern logger conf_logger(); // start processing info!("predict example started"); let tle: Tle = Tle { name: "GRIFEX".to_string(), line1: "1 40379U 15003D 15243.42702278 .00003367 00000-0 17130-3 0 9993".to_string(), line2: "2 40379 99.1124 290.6779 01570...
main
identifier_name
win_delay_load_hook.rs
//! Rust port of [win_delay_load_hook.cc][]. //! //! When the addon tries to load the "node.exe" DLL module, this module gives it the pointer to the //!.exe we are running in instead. Typically, that will be the same value. But if the node executable //! was renamed, you would not otherwise get the correct DLL. //! //!...
} #[allow(non_snake_case)] type PfnDliHook = unsafe extern "C" fn(dliNotify: usize, pdli: *const DelayLoadInfo) -> FARPROC; const HOST_BINARIES: &[&[u8]] = &[b"node.exe", b"electron.exe"]; unsafe extern "C" fn load_exe_hook(event: usize, info: *const DelayLoadInfo) -> FARPROC { if event!= 0x01 /* dliNotePreLoad...
dwLastError: DWORD,
random_line_split
win_delay_load_hook.rs
//! Rust port of [win_delay_load_hook.cc][]. //! //! When the addon tries to load the "node.exe" DLL module, this module gives it the pointer to the //!.exe we are running in instead. Typically, that will be the same value. But if the node executable //! was renamed, you would not otherwise get the correct DLL. //! //!...
{ /// size of structure cb: DWORD, /// raw form of data (everything is there) /// Officially a pointer to ImgDelayDescr but we don't access it. pidd: LPVOID, /// points to address of function to load ppfn: *mut FARPROC, /// name of dll szDll: LPCSTR, /// name or ordinal of proce...
DelayLoadInfo
identifier_name
win_delay_load_hook.rs
//! Rust port of [win_delay_load_hook.cc][]. //! //! When the addon tries to load the "node.exe" DLL module, this module gives it the pointer to the //!.exe we are running in instead. Typically, that will be the same value. But if the node executable //! was renamed, you would not otherwise get the correct DLL. //! //!...
let dll_name = CStr::from_ptr((*info).szDll); if!HOST_BINARIES.iter().any(|&host_name| host_name == dll_name.to_bytes()) { return null_mut(); } let exe_handle = GetModuleHandleA(null_mut()); // PfnDliHook sometimes has to return a FARPROC, sometimes an HMODULE, but only one // of the...
{ return null_mut(); }
conditional_block
lib.rs
//! [![logo](http://i.imgur.com/dnpEXyh.jpg)](http://i.imgur.com/RUEw8EW.png) //! //! bspline //! === //! A library for computing B-spline interpolating curves on generic control points. bspline can //! be used to evaluate B-splines of varying orders on any type that can be linearly interpolated, //! ranging from float...
} /// Return the index of the first element greater than the value passed. /// The data **must** be sorted. If no element greater than the value /// passed is found the function returns None. fn upper_bounds<F: Float>(data: &[F], value: F) -> Option<usize> { let mut first = 0usize; let mut step; let mut c...
{ let mut tmp = Vec::with_capacity(self.degree + 1); for j in 0..=self.degree { let p = j + i_start - self.degree - 1; tmp.push(self.control_points[p]); } for lvl in 0..self.degree { let k = lvl + 1; for j in 0..self.degree - lvl { ...
identifier_body
lib.rs
//! [![logo](http://i.imgur.com/dnpEXyh.jpg)](http://i.imgur.com/RUEw8EW.png) //! //! bspline //! === //! A library for computing B-spline interpolating curves on generic control points. bspline can //! be used to evaluate B-splines of varying orders on any type that can be linearly interpolated, //! ranging from float...
(&self, t: F, i_start: usize) -> T { let mut tmp = Vec::with_capacity(self.degree + 1); for j in 0..=self.degree { let p = j + i_start - self.degree - 1; tmp.push(self.control_points[p]); } for lvl in 0..self.degree { let k = lvl + 1; for j...
de_boor_iterative
identifier_name
lib.rs
//! [![logo](http://i.imgur.com/dnpEXyh.jpg)](http://i.imgur.com/RUEw8EW.png) //! //! bspline //! === //! A library for computing B-spline interpolating curves on generic control points. bspline can //! be used to evaluate B-splines of varying orders on any type that can be linearly interpolated, //! ranging from float...
if knots.len()!= control_points.len() + degree + 1 { panic!( "Invalid number of knots, got {}, expected {}", knots.len(), control_points.len() + degree + 1 ); } knots.sort_by(|a, b| a.partial_cmp(b).unwrap()); BSpli...
{ panic!("Too few control points for curve"); }
conditional_block
lib.rs
//! [![logo](http://i.imgur.com/dnpEXyh.jpg)](http://i.imgur.com/RUEw8EW.png) //! //! bspline //! === //! A library for computing B-spline interpolating curves on generic control points. bspline can //! be used to evaluate B-splines of varying orders on any type that can be linearly interpolated, //! ranging from float...
Some(x) => x, None => self.knots.len() - self.degree - 1, }; self.de_boor_iterative(t, i) } /// Get an iterator over the control points. pub fn control_points(&self) -> Iter<T> { self.control_points.iter() } /// Get an iterator over the knots. pub ...
let i = match upper_bounds(&self.knots[..], t) { Some(x) if x == 0 => self.degree, Some(x) if x >= self.knots.len() - self.degree - 1 => { self.knots.len() - self.degree - 1 }
random_line_split
mark.rs
use std; pub trait Marker { fn mark(&mut self, s: usize) -> &Marker; fn is_marked(&self, s: usize) -> bool; } pub struct TMarker { marks: Vec<u32>, marking: u32 } impl Marker for TMarker { fn mark(&mut self, s: usize) -> &Marker { self.marks[s] = self.marking; self } fn is...
} impl TMarker { pub fn new(n: usize) -> TMarker { TMarker { marks: vec![0; n], marking: 1 } } pub fn reset(&mut self) -> &TMarker { if self.marking < std::u32::MAX { self.marking += 1; } else { for i in &mut self.marks { *i = 0; }...
{ self.marks[s] == self.marking }
identifier_body
mark.rs
use std; pub trait Marker { fn mark(&mut self, s: usize) -> &Marker; fn is_marked(&self, s: usize) -> bool; } pub struct TMarker { marks: Vec<u32>, marking: u32 } impl Marker for TMarker { fn mark(&mut self, s: usize) -> &Marker { self.marks[s] = self.marking; self } fn is...
else { for i in &mut self.marks { *i = 0; } } self } }
{ self.marking += 1; }
conditional_block
mark.rs
use std; pub trait Marker { fn mark(&mut self, s: usize) -> &Marker; fn is_marked(&self, s: usize) -> bool; } pub struct TMarker { marks: Vec<u32>, marking: u32 } impl Marker for TMarker { fn mark(&mut self, s: usize) -> &Marker { self.marks[s] = self.marking; self } fn is...
(n: usize) -> TMarker { TMarker { marks: vec![0; n], marking: 1 } } pub fn reset(&mut self) -> &TMarker { if self.marking < std::u32::MAX { self.marking += 1; } else { for i in &mut self.marks { *i = 0; } } self } }
new
identifier_name
mark.rs
use std; pub trait Marker { fn mark(&mut self, s: usize) -> &Marker; fn is_marked(&self, s: usize) -> bool; } pub struct TMarker { marks: Vec<u32>, marking: u32 } impl Marker for TMarker { fn mark(&mut self, s: usize) -> &Marker { self.marks[s] = self.marking; self } fn is...
for i in &mut self.marks { *i = 0; } } self } }
} else {
random_line_split
oneshot.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self, t: T) -> Result<(), T> { unsafe { // Sanity check match *self.upgrade.get() { NothingSent => {} _ => panic!("sending on a oneshot that's already sent on "), } assert!((*self.data.get()).is_none()); ptr::write(sel...
send
identifier_name
oneshot.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 ...
} else { // drop the signal token, since we never blocked drop(unsafe { SignalToken::cast_from_usize(ptr) }); } } self.try_recv() } pub fn try_recv(&self) -> Result<T, Failure<T>> { unsafe { match self.state.load(Orde...
{ wait_token.wait(); debug_assert!(self.state.load(Ordering::SeqCst) != EMPTY); }
conditional_block
oneshot.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 ...
// There's data on the channel, so make sure we destroy it promptly. // This is why not using an arc is a little difficult (need the box // to stay valid while we take the data). DATA => unsafe { (&mut *self.data.get()).take().unwrap(); }, // We're the only ...
// An empty channel has nothing to do, and a remotely disconnected // channel also has nothing to do b/c we're about to run the drop // glue DISCONNECTED | EMPTY => {}
random_line_split
morestack4.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 ...
and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(1); }; }
fn and_then_get_big_again(x:int) -> and_then_get_big_again {
random_line_split
morestack4.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 ...
} struct and_then_get_big_again { x:int, } impl Drop for and_then_get_big_again { fn finalize(&self) {} } fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(1); }; }
{ fail!(); }
conditional_block
morestack4.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ x:int, } impl Drop for and_then_get_big_again { fn finalize(&self) {} } fn and_then_get_big_again(x:int) -> and_then_get_big_again { and_then_get_big_again { x: x } } fn main() { do task::spawn { getbig_and_fail(1); }; }
and_then_get_big_again
identifier_name
morestack4.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 ...
; }
{ do task::spawn { getbig_and_fail(1); }
identifier_body
gemm.rs
//! C := alpha * A * B + beta * C use complex::Complex; use {Transpose, blasint, ffi}; /// The signature of `gemm` pub type Fn<T> = unsafe extern "C" fn ( *const Transpose, *const Transpose, *const blasint, *const blasint, *const blasint, *const T, *const T, *const blasint, *const...
() -> Fn<f64> { ffi::dgemm_ } }
gemm
identifier_name
gemm.rs
//! C := alpha * A * B + beta * C use complex::Complex; use {Transpose, blasint, ffi}; /// The signature of `gemm` pub type Fn<T> = unsafe extern "C" fn ( *const Transpose, *const Transpose, *const blasint, *const blasint, *const blasint, *const T, *const T, *const blasint, *const...
} impl ::Gemm for f64 { fn gemm() -> Fn<f64> { ffi::dgemm_ } }
{ ffi::sgemm_ }
identifier_body
gemm.rs
//! C := alpha * A * B + beta * C use complex::Complex; use {Transpose, blasint, ffi}; /// The signature of `gemm` pub type Fn<T> = unsafe extern "C" fn ( *const Transpose, *const Transpose, *const blasint, *const blasint, *const blasint, *const T, *const T, *const blasint, *const...
impl ::Gemm for f32 { fn gemm() -> Fn<f32> { ffi::sgemm_ } } impl ::Gemm for f64 { fn gemm() -> Fn<f64> { ffi::dgemm_ } }
ffi::zgemm_ } }
random_line_split
value_oid_as.rs
#![allow(dead_code)] #![allow(unused_imports)] extern crate libc; extern crate sysctl; // Import the trait use sysctl::Sysctl; // Converted from definition in from /usr/include/sys/time.h #[derive(Debug)] #[repr(C)] struct ClockInfo { hz: libc::c_int, /* clock frequency */ tick: libc::c_int, /* micro-secon...
() { println!("This operation is not supported on Linux."); }
main
identifier_name
value_oid_as.rs
#![allow(dead_code)] #![allow(unused_imports)] extern crate libc; extern crate sysctl; // Import the trait use sysctl::Sysctl; // Converted from definition in from /usr/include/sys/time.h #[derive(Debug)] #[repr(C)] struct ClockInfo { hz: libc::c_int, /* clock frequency */ tick: libc::c_int, /* micro-secon...
#[cfg(any(target_os = "linux", target_os = "android"))] fn main() { println!("This operation is not supported on Linux."); }
random_line_split
value_oid_as.rs
#![allow(dead_code)] #![allow(unused_imports)] extern crate libc; extern crate sysctl; // Import the trait use sysctl::Sysctl; // Converted from definition in from /usr/include/sys/time.h #[derive(Debug)] #[repr(C)] struct ClockInfo { hz: libc::c_int, /* clock frequency */ tick: libc::c_int, /* micro-secon...
#[cfg(any(target_os = "linux", target_os = "android"))] fn main() { println!("This operation is not supported on Linux."); }
{ let oid: Vec<i32> = vec![libc::CTL_KERN, libc::KERN_CLOCKRATE]; let val: Box<ClockInfo> = sysctl::Ctl { oid }.value_as().expect("could not get value"); println!("{:?}", val); }
identifier_body
supertypes.rs
use super::{general::StatusedTypeId, imports::Imports}; use crate::{ analysis::{namespaces, rust_type::used_rust_type}, env::Env, library::TypeId, }; pub fn analyze(env: &Env, type_id: TypeId, imports: &mut Imports) -> Vec<StatusedTypeId> { let mut parents = Vec::new(); let gobject_id = env.library...
(env: &Env, type_id: TypeId) -> Vec<TypeId> { let mut parents = Vec::new(); let gobject_id = match env.library.find_type(0, "GObject.Object") { Some(gobject_id) => gobject_id, None => TypeId::tid_none(), }; for &super_tid in env.class_hierarchy.supertypes(type_id) { // skip GObj...
dependencies
identifier_name
supertypes.rs
use super::{general::StatusedTypeId, imports::Imports}; use crate::{ analysis::{namespaces, rust_type::used_rust_type}, env::Env, library::TypeId, }; pub fn analyze(env: &Env, type_id: TypeId, imports: &mut Imports) -> Vec<StatusedTypeId> { let mut parents = Vec::new(); let gobject_id = env.library...
} } parents } pub fn dependencies(env: &Env, type_id: TypeId) -> Vec<TypeId> { let mut parents = Vec::new(); let gobject_id = match env.library.find_type(0, "GObject.Object") { Some(gobject_id) => gobject_id, None => TypeId::tid_none(), }; for &super_tid in env.class_...
{ if super_tid.ns_id == namespaces::MAIN { imports.add(&s); } else { let ns = &env.namespaces[super_tid.ns_id]; imports.add(&ns.crate_name); } }
conditional_block
supertypes.rs
use super::{general::StatusedTypeId, imports::Imports}; use crate::{ analysis::{namespaces, rust_type::used_rust_type}, env::Env, library::TypeId, }; pub fn analyze(env: &Env, type_id: TypeId, imports: &mut Imports) -> Vec<StatusedTypeId> { let mut parents = Vec::new(); let gobject_id = env.library...
parents }
{ let mut parents = Vec::new(); let gobject_id = match env.library.find_type(0, "GObject.Object") { Some(gobject_id) => gobject_id, None => TypeId::tid_none(), }; for &super_tid in env.class_hierarchy.supertypes(type_id) { // skip GObject, it's inherited implicitly if su...
identifier_body
supertypes.rs
use super::{general::StatusedTypeId, imports::Imports}; use crate::{ analysis::{namespaces, rust_type::used_rust_type}, env::Env, library::TypeId, }; pub fn analyze(env: &Env, type_id: TypeId, imports: &mut Imports) -> Vec<StatusedTypeId> { let mut parents = Vec::new(); let gobject_id = env.library...
status, }); if!status.ignored() { if let Ok(s) = used_rust_type(env, super_tid, true) { if super_tid.ns_id == namespaces::MAIN { imports.add(&s); } else { let ns = &env.namespaces[super_tid.ns_id]; ...
parents.push(StatusedTypeId { type_id: super_tid, name: env.library.type_(super_tid).get_name(),
random_line_split
testbindingpairiterable.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/. */ // check-tidy: no specs after this line use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings...
} impl TestBindingPairIterable { fn new(global: GlobalRef) -> Root<TestBindingPairIterable> { reflect_dom_object(box TestBindingPairIterable { reflector: Reflector::new(), map: DOMRefCell::new(vec![]), }, global, TestBindingPairIterableBinding::TestBindingPairIterableWrap) ...
{ self.map.borrow().iter().nth(index as usize).map(|a| &a.0).unwrap().clone() }
identifier_body
testbindingpairiterable.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/. */ // check-tidy: no specs after this line use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings...
self.map.borrow().iter().nth(index as usize).map(|a| &a.1).unwrap().clone() } fn get_key_at_index(&self, index: u32) -> DOMString { self.map.borrow().iter().nth(index as usize).map(|a| &a.0).unwrap().clone() } } impl TestBindingPairIterable { fn new(global: GlobalRef) -> Root<TestBindin...
self.map.borrow().len() as u32 } fn get_value_at_index(&self, index: u32) -> u32 {
random_line_split
testbindingpairiterable.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/. */ // check-tidy: no specs after this line use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings...
(global: GlobalRef) -> Root<TestBindingPairIterable> { reflect_dom_object(box TestBindingPairIterable { reflector: Reflector::new(), map: DOMRefCell::new(vec![]), }, global, TestBindingPairIterableBinding::TestBindingPairIterableWrap) } pub fn Constructor(global: GlobalR...
new
identifier_name
main.rs
// // George 'papanikge' Papanikolaou 2014-2018 // tail + head = tead // // This was originally written in an ancient form of rust. // Rewritten for rust 1.22. // extern crate getopts; use getopts::Options; // use extra::getopts::{optopt, optflag, getopts}; // renamed to BufReader. but probaby do not want it // use st...
usage(&program_name); return; // No files provided. stdin() is a reader so we can do: // let mut buffer = BufferedReader::new(std::io::stdin()); // call tead here } else { println!("temp - lines: {}", lines); files[0].clone(); // call tead here } }
let lines = given.opt_str("n").or(Some(String::from(DEFAULT_LINE_NUMBER))).unwrap(); let files = given.free; if files.is_empty() {
random_line_split
main.rs
// // George 'papanikge' Papanikolaou 2014-2018 // tail + head = tead // // This was originally written in an ancient form of rust. // Rewritten for rust 1.22. // extern crate getopts; use getopts::Options; // use extra::getopts::{optopt, optflag, getopts}; // renamed to BufReader. but probaby do not want it // use st...
() { let args: Vec<String> = env::args().collect(); let program_name = args[0].clone(); let mut available = Options::new(); available.optopt("n", "lines-number", "number of lines to print [default: 5]", ""); available.optflag("v", "version", "print tead's version"); available.optflag("h", "help...
main
identifier_name
main.rs
// // George 'papanikge' Papanikolaou 2014-2018 // tail + head = tead // // This was originally written in an ancient form of rust. // Rewritten for rust 1.22. // extern crate getopts; use getopts::Options; // use extra::getopts::{optopt, optflag, getopts}; // renamed to BufReader. but probaby do not want it // use st...
let lines = given.opt_str("n").or(Some(String::from(DEFAULT_LINE_NUMBER))).unwrap(); let files = given.free; if files.is_empty() { usage(&program_name); return; // No files provided. stdin() is a reader so we can do: // let mut buffer = BufferedReader::new(std::io::stdin()...
{ println!("tead -- Version {}", VERSION); return; }
conditional_block
main.rs
// // George 'papanikge' Papanikolaou 2014-2018 // tail + head = tead // // This was originally written in an ancient form of rust. // Rewritten for rust 1.22. // extern crate getopts; use getopts::Options; // use extra::getopts::{optopt, optflag, getopts}; // renamed to BufReader. but probaby do not want it // use st...
fn main() { let args: Vec<String> = env::args().collect(); let program_name = args[0].clone(); let mut available = Options::new(); available.optopt("n", "lines-number", "number of lines to print [default: 5]", ""); available.optflag("v", "version", "print tead's version"); available.optflag("...
{ println!("Usage: {} [options]", program_name); println!("\t-n <number of lines to print>"); println!("\t-h --help"); println!("\t-v --version"); }
identifier_body
main.rs
#![feature(plugin, start)] #![no_std] #![plugin(macro_zinc)] extern crate zinc; #[zinc_main] fn
() { use zinc::drivers::chario::CharIO; use zinc::hal; use zinc::hal::pin::Gpio; use zinc::hal::stm32f1::{init, pin, usart}; // configure PLL and set it as System Clock source let pll_conf = init::PllConf { source: init::PllClockSource::PllSourceHSE(8_000_000), mult: init::PllMult:...
main
identifier_name
main.rs
#![feature(plugin, start)] #![no_std] #![plugin(macro_zinc)] extern crate zinc; #[zinc_main] fn main() { use zinc::drivers::chario::CharIO; use zinc::hal; use zinc::hal::pin::Gpio; use zinc::hal::stm32f1::{init, pin, usart}; // configure PLL and set it as System Clock source let pll_conf = init::PllConf...
usb_prescaler: init::PllUsbDiv::PllUsbDiv1p5, }; let sys_clock = init::ClockConfig { source: init::SystemClockSource::SystemClockPLL(pll_conf), ahb_prescaler: init::ClockAhbPrescaler::AhbDivNone, apb1_prescaler: init::ClockApbPrescaler::ApbDiv2, apb2_prescaler: init::ClockApbPre...
hse_prediv: init::PllHsePrediv::PllHsePrediv1,
random_line_split
main.rs
#![feature(plugin, start)] #![no_std] #![plugin(macro_zinc)] extern crate zinc; #[zinc_main] fn main()
}; sys_clock.setup(); let _pin_tx = pin::Pin::new(pin::Port::PortA, 2, pin::PinConf::OutPushPullAlt2MHz); let led1 = pin::Pin::new(pin::Port::PortC, 13, pin::PinConf::OutPushPull50MHz); led1.set_low(); let uart = usart::Usart::new(usart::UsartPeripheral::Usart2, 38400, usart::WordLen::WordLen8bits, ...
{ use zinc::drivers::chario::CharIO; use zinc::hal; use zinc::hal::pin::Gpio; use zinc::hal::stm32f1::{init, pin, usart}; // configure PLL and set it as System Clock source let pll_conf = init::PllConf { source: init::PllClockSource::PllSourceHSE(8_000_000), mult: init::PllMult::Pl...
identifier_body
rt_multi_threaded.rs
//! Benchmark implementation details of the threaded scheduler. These benches are //! intended to be used as a form of regression testing and not as a general //! purpose benchmark demonstrating real-world performance. use tokio::runtime::{self, Runtime}; use tokio::sync::oneshot; use bencher::{benchmark_group, bench...
(b: &mut Bencher) { const NUM_PINGS: usize = 1_000; let rt = rt(); let (done_tx, done_rx) = mpsc::sync_channel(1000); let rem = Arc::new(AtomicUsize::new(0)); b.iter(|| { let done_tx = done_tx.clone(); let rem = rem.clone(); rem.store(NUM_PINGS, Relaxed); rt.block...
ping_pong
identifier_name
rt_multi_threaded.rs
//! Benchmark implementation details of the threaded scheduler. These benches are //! intended to be used as a form of regression testing and not as a general //! purpose benchmark demonstrating real-world performance. use tokio::runtime::{self, Runtime}; use tokio::sync::oneshot; use bencher::{benchmark_group, bench...
benchmark_group!(scheduler, spawn_many, ping_pong, yield_many, chained_spawn,); benchmark_main!(scheduler);
{ runtime::Builder::new_multi_thread() .worker_threads(4) .enable_all() .build() .unwrap() }
identifier_body
rt_multi_threaded.rs
//! Benchmark implementation details of the threaded scheduler. These benches are //! intended to be used as a form of regression testing and not as a general //! purpose benchmark demonstrating real-world performance. use tokio::runtime::{self, Runtime}; use tokio::sync::oneshot; use bencher::{benchmark_group, bench...
else { tokio::spawn(async move { iter(done_tx, n - 1); }); } } let (done_tx, done_rx) = mpsc::sync_channel(1000); b.iter(move || { let done_tx = done_tx.clone(); rt.block_on(async { tokio::spawn(async move { iter...
{ done_tx.send(()).unwrap(); }
conditional_block
rt_multi_threaded.rs
//! Benchmark implementation details of the threaded scheduler. These benches are //! intended to be used as a form of regression testing and not as a general //! purpose benchmark demonstrating real-world performance. use tokio::runtime::{self, Runtime}; use tokio::sync::oneshot; use bencher::{benchmark_group, bench...
tx.send(()).unwrap(); }); } for _ in 0..TASKS { let _ = rx.recv().unwrap(); } }); } fn ping_pong(b: &mut Bencher) { const NUM_PINGS: usize = 1_000; let rt = rt(); let (done_tx, done_rx) = mpsc::sync_channel(1000); let rem = Arc::ne...
rt.spawn(async move { for _ in 0..NUM_YIELD { tokio::task::yield_now().await; }
random_line_split
deriving-zero.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} } } #[deriving(Zero)] struct Vector3<T> { x: T, y: T, z: T, } impl<T: Add<T, T>> Add<Vector3<T>, Vector3<T>> for Vector3<T> { fn add(&self, other: &Vector3<T>) -> Vector3<T> { Vector3 { x: self.x + other.x, y: self.y + other.y, z: self.z + other.z, ...
{ Vector2(*x0 + *x1, *y0 + *y1) }
conditional_block
deriving-zero.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
<T> { x: Vector2<T>, y: Vector2<T>, z: Vector2<T>, } impl<T: Add<T, T>> Add<Matrix3x2<T>, Matrix3x2<T>> for Matrix3x2<T> { fn add(&self, other: &Matrix3x2<T>) -> Matrix3x2<T> { Matrix3x2 { x: self.x + other.x, y: self.y + other.y, z: self.z + other.z, ...
Matrix3x2
identifier_name
deriving-zero.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
let _: Matrix3x2<u8> = Zero::zero(); }
random_line_split
deriving-zero.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} #[deriving(Zero)] struct Vector3<T> { x: T, y: T, z: T, } impl<T: Add<T, T>> Add<Vector3<T>, Vector3<T>> for Vector3<T> { fn add(&self, other: &Vector3<T>) -> Vector3<T> { Vector3 { x: self.x + other.x, y: self.y + other.y, z: self.z + other.z, } } } ...
{ match (self, other) { (&Vector2(ref x0, ref y0), &Vector2(ref x1, ref y1)) => { Vector2(*x0 + *x1, *y0 + *y1) } } }
identifier_body
persistent_liveness_storage.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{consensusdb::ConsensusDB, epoch_manager::LivenessStorageData, error::DbError}; use anyhow::{format_err, Context, Result}; use consensus_types::{ block::Block, quorum_cert::QuorumCert, timeout_certificate::TimeoutCertific...
fn prune_tree(&self, block_ids: Vec<HashValue>) -> Result<()> { if!block_ids.is_empty() { // quorum certs that certified the block_ids will get removed self.db.delete_blocks_and_quorum_certificates(block_ids)?; } Ok(()) } fn save_vote(&self, vote: &Vote) ->...
{ let mut trace_batch = vec![]; for block in blocks.iter() { trace_code_block!("consensusdb::save_tree", {"block", block.id()}, trace_batch); } Ok(self .db .save_blocks_and_quorum_certificates(blocks, quorum_certs)?) }
identifier_body
persistent_liveness_storage.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{consensusdb::ConsensusDB, epoch_manager::LivenessStorageData, error::DbError}; use anyhow::{format_err, Context, Result}; use consensus_types::{ block::Block, quorum_cert::QuorumCert, timeout_certificate::TimeoutCertific...
} pub fn root_block(&self) -> &Block { &self.root.0 } pub fn last_vote(&self) -> Option<Vote> { self.last_vote.clone() } pub fn take(self) -> (RootInfo, RootMetadata, Vec<Block>, Vec<QuorumCert>) { ( self.root, self.root_metadata, se...
}, })
random_line_split
persistent_liveness_storage.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{consensusdb::ConsensusDB, epoch_manager::LivenessStorageData, error::DbError}; use anyhow::{format_err, Context, Result}; use consensus_types::{ block::Block, quorum_cert::QuorumCert, timeout_certificate::TimeoutCertific...
Ok(()) } fn save_vote(&self, vote: &Vote) -> Result<()> { Ok(self.db.save_vote(bcs::to_bytes(vote)?)?) } fn recover_from_ledger(&self) -> LedgerRecoveryData { let startup_info = self .diem_db .get_startup_info() .expect("unable to read ledger i...
{ // quorum certs that certified the block_ids will get removed self.db.delete_blocks_and_quorum_certificates(block_ids)?; }
conditional_block
persistent_liveness_storage.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{consensusdb::ConsensusDB, epoch_manager::LivenessStorageData, error::DbError}; use anyhow::{format_err, Context, Result}; use consensus_types::{ block::Block, quorum_cert::QuorumCert, timeout_certificate::TimeoutCertific...
(&self) -> Round { self.storage_ledger.round() } /// Finds the root (last committed block) and returns the root block, the QC to the root block /// and the ledger info for the root block, return an error if it can not be found. /// /// We guarantee that the block corresponding to the storag...
commit_round
identifier_name
issue-18959.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T>(&self, _: &T) {} } #[inline(never)] fn foo(b: &Bar) { b.foo(&0us) } fn main() { let mut thing = Thing; let test: &Bar = &mut thing; //~ ERROR cannot convert to a trait object foo(test); }
foo
identifier_name
issue-18959.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except accordin...
random_line_split
kraken.rs
#[cfg(test)] mod kraken_tests { extern crate coinnect; use self::coinnect::bitstamp::BitstampCreds; use self::coinnect::kraken::{KrakenApi, KrakenCreds}; #[test] fn fail_with_invalid_creds() { let creds = BitstampCreds::new("", "", "", ""); let res = KrakenApi::new(creds); ...
}
}
random_line_split
kraken.rs
#[cfg(test)] mod kraken_tests { extern crate coinnect; use self::coinnect::bitstamp::BitstampCreds; use self::coinnect::kraken::{KrakenApi, KrakenCreds}; #[test] fn fail_with_invalid_creds() { let creds = BitstampCreds::new("", "", "", ""); let res = KrakenApi::new(creds); ...
/// IMPORTANT: Real keys are needed in order to retrieve a token #[test] #[cfg_attr(not(feature = "kraken_private_tests"), ignore)] fn get_websockets_token_should_return_a_token() { use std::path::PathBuf; let path = PathBuf::from("./keys_real.json"); let creds = KrakenCreds::n...
{ use std::path::PathBuf; let path = PathBuf::from("./keys_real.json"); let creds = KrakenCreds::new_from_file("account_kraken", path).unwrap(); let mut api = KrakenApi::new(creds).unwrap(); let result = api.get_account_balance().unwrap(); println!("{:?}", result); ...
identifier_body
kraken.rs
#[cfg(test)] mod kraken_tests { extern crate coinnect; use self::coinnect::bitstamp::BitstampCreds; use self::coinnect::kraken::{KrakenApi, KrakenCreds}; #[test] fn
() { let creds = BitstampCreds::new("", "", "", ""); let res = KrakenApi::new(creds); assert_eq!( res.unwrap_err().to_string(), "Invalid config: \nExpected: Kraken\nFind: Bitstamp" ); } /// IMPORTANT: Real keys are needed in order to retrieve the balance ...
fail_with_invalid_creds
identifier_name
common.rs
//! Set of common types used through the app use async_std::sync::Arc; use std::fmt; use std::slice::Iter; use std::time::Instant; use unicode_segmentation::UnicodeSegmentation; pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; /// The Prompt represents the current query, the cur...
else { self.len() - self.cursor } } pub fn as_string(&self) -> String { self.query.iter().collect() } pub fn timestamp(&self) -> Instant { self.timestamp } pub fn len(&self) -> usize { self.query.len() } pub fn is_empty(&self) -> bool { ...
{ 0 }
conditional_block
common.rs
//! Set of common types used through the app use async_std::sync::Arc; use std::fmt; use std::slice::Iter; use std::time::Instant; use unicode_segmentation::UnicodeSegmentation; pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; /// The Prompt represents the current query, the cur...
(&self) -> Iter<'_, String> { self.graphemes_lw.iter() } pub fn is_empty(&self) -> bool { self.string.is_empty() } } impl From<&str> for Letters { fn from(string: &str) -> Self { Self::new(String::from(string)) } } impl From<String> for Letters { fn from(string: String...
lowercase_iter
identifier_name
common.rs
//! Set of common types used through the app use async_std::sync::Arc; use std::fmt; use std::slice::Iter; use std::time::Instant; use unicode_segmentation::UnicodeSegmentation; pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; /// The Prompt represents the current query, the cur...
pub fn cursor_until_end(&self) -> usize { if self.len() < self.cursor { 0 } else { self.len() - self.cursor } } pub fn as_string(&self) -> String { self.query.iter().collect() } pub fn timestamp(&self) -> Instant { self.timestamp ...
random_line_split
common.rs
//! Set of common types used through the app use async_std::sync::Arc; use std::fmt; use std::slice::Iter; use std::time::Instant; use unicode_segmentation::UnicodeSegmentation; pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; /// The Prompt represents the current query, the cur...
pub fn refresh(&mut self) { self.timestamp = Instant::now(); } } impl From<&String> for Prompt { fn from(string: &String) -> Self { let query = string.chars().collect::<Vec<char>>(); let cursor = query.len(); Self { query, cursor, ..Defa...
{ self.query.is_empty() }
identifier_body
parity.rs
use malachite_base::num::arithmetic::traits::Parity; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::runner::Runner; use malachite_nz_test_util::bench::bucketers::natural_bit_bucketer; use malachit...
(gm: GenMode, config: GenConfig, limit: usize, file_name: &str) { run_benchmark( "Natural.even()", BenchmarkType::Single, natural_gen().get(gm, &config), gm.name(), limit, file_name, &natural_bit_bucketer("n"), &mut [("Malachite", &mut |n| no_out!(n.ev...
benchmark_natural_even
identifier_name
parity.rs
use malachite_base::num::arithmetic::traits::Parity; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::runner::Runner; use malachite_nz_test_util::bench::bucketers::natural_bit_bucketer; use malachit...
"Natural.even()", BenchmarkType::Single, natural_gen().get(gm, &config), gm.name(), limit, file_name, &natural_bit_bucketer("n"), &mut [("Malachite", &mut |n| no_out!(n.even()))], ); } fn benchmark_natural_odd(gm: GenMode, config: GenConfig, limit: us...
fn benchmark_natural_even(gm: GenMode, config: GenConfig, limit: usize, file_name: &str) { run_benchmark(
random_line_split
parity.rs
use malachite_base::num::arithmetic::traits::Parity; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::runner::Runner; use malachite_nz_test_util::bench::bucketers::natural_bit_bucketer; use malachit...
fn benchmark_natural_odd(gm: GenMode, config: GenConfig, limit: usize, file_name: &str) { run_benchmark( "Natural.odd()", BenchmarkType::Single, natural_gen().get(gm, &config), gm.name(), limit, file_name, &natural_bit_bucketer("n"), &mut [("Malachit...
{ run_benchmark( "Natural.even()", BenchmarkType::Single, natural_gen().get(gm, &config), gm.name(), limit, file_name, &natural_bit_bucketer("n"), &mut [("Malachite", &mut |n| no_out!(n.even()))], ); }
identifier_body
parity.rs
use malachite_base::num::arithmetic::traits::Parity; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::runner::Runner; use malachite_nz_test_util::bench::bucketers::natural_bit_bucketer; use malachit...
else { println!("{} is not odd", n); } } } fn benchmark_natural_even(gm: GenMode, config: GenConfig, limit: usize, file_name: &str) { run_benchmark( "Natural.even()", BenchmarkType::Single, natural_gen().get(gm, &config), gm.name(), limit, fi...
{ println!("{} is odd", n); }
conditional_block
pipeline.rs
use super::config::AgentConfig; use super::source::Source; use super::target::Target; use super::source::SourceBuilder; use super::target::TargetBuilder; use super::lang::SquiddyProgram; use super::lang::ast::Parser; use super::lang::compiler::Compiler; use super::lang::token::Tokenizer; use std::io::{Error, ErrorKind}...
}
{ while self.source.has_more() { let item = self.source.next(); for condition in &mut self.program.conditions { if condition.matcher.accept(&item) { for action in &mut condition.actions { if let Some(events) = action.perform()...
identifier_body
pipeline.rs
use super::config::AgentConfig; use super::source::Source; use super::target::Target; use super::source::SourceBuilder; use super::target::TargetBuilder; use super::lang::SquiddyProgram; use super::lang::ast::Parser; use super::lang::compiler::Compiler; use super::lang::token::Tokenizer; use std::io::{Error, ErrorKind}...
else { Err(Error::new(ErrorKind::Other, "No source definition found")) } } fn compile_program(_: &AgentConfig) -> Result<SquiddyProgram, Error> { Parser::parse(&Tokenizer::tokenize(Bytes::from("{hello world}"))) // TODO better error conversion .map_err(|_| Error::new...
{ if let Ok(target) = TargetBuilder::build(config.target_type) { Ok(Pipeline { source: source, target: target, program: program }) } else { Err(Error::new(ErrorKind::Other, "No target defi...
conditional_block
pipeline.rs
use super::config::AgentConfig; use super::source::Source; use super::target::Target; use super::source::SourceBuilder; use super::target::TargetBuilder; use super::lang::SquiddyProgram; use super::lang::ast::Parser; use super::lang::compiler::Compiler; use super::lang::token::Tokenizer; use std::io::{Error, ErrorKind}...
} } else { Err(Error::new(ErrorKind::Other, "No source definition found")) } } fn compile_program(_: &AgentConfig) -> Result<SquiddyProgram, Error> { Parser::parse(&Tokenizer::tokenize(Bytes::from("{hello world}"))) // TODO better error conversion ...
random_line_split
pipeline.rs
use super::config::AgentConfig; use super::source::Source; use super::target::Target; use super::source::SourceBuilder; use super::target::TargetBuilder; use super::lang::SquiddyProgram; use super::lang::ast::Parser; use super::lang::compiler::Compiler; use super::lang::token::Tokenizer; use std::io::{Error, ErrorKind}...
(&mut self) -> () { while self.source.has_more() { let item = self.source.next(); for condition in &mut self.program.conditions { if condition.matcher.accept(&item) { for action in &mut condition.actions { if let Some(events) ...
run
identifier_name
parse_and_typecheck.rs
use crate::ProtoPathBuf; /// Result of parsing `.proto` files. #[doc(hidden)] pub struct ParsedAndTypechecked { /// One entry for each input `.proto` file. pub relative_paths: Vec<ProtoPathBuf>, /// All parsed `.proto` files including dependencies of input files. pub file_descriptors: Vec<protobuf::des...
HashSet::from(["a.proto", "b.proto"]), protoc.file_descriptors.iter().map(|d| d.name()).collect() ); assert_eq!(1, protoc.file_descriptors[0].message_type.len()); assert_eq!(1, pure.file_descriptors[0].message_type.len()); assert_eq!( "Banana", ...
random_line_split
parse_and_typecheck.rs
use crate::ProtoPathBuf; /// Result of parsing `.proto` files. #[doc(hidden)] pub struct
{ /// One entry for each input `.proto` file. pub relative_paths: Vec<ProtoPathBuf>, /// All parsed `.proto` files including dependencies of input files. pub file_descriptors: Vec<protobuf::descriptor::FileDescriptorProto>, /// Description of the parser (e.g. to include in generated files). pub...
ParsedAndTypechecked
identifier_name
parse_and_typecheck.rs
use crate::ProtoPathBuf; /// Result of parsing `.proto` files. #[doc(hidden)] pub struct ParsedAndTypechecked { /// One entry for each input `.proto` file. pub relative_paths: Vec<ProtoPathBuf>, /// All parsed `.proto` files including dependencies of input files. pub file_descriptors: Vec<protobuf::des...
.input(&b_proto) .parse_and_typecheck() .unwrap(); assert_eq!(pure.relative_paths, protoc.relative_paths); assert_eq!(2, pure.file_descriptors.len()); assert_eq!(2, protoc.file_descriptors.len()); // TODO: make result more deterministic assert_eq...
{ let dir = tempfile::tempdir().unwrap(); let a_proto = dir.path().join("a.proto"); let b_proto = dir.path().join("b.proto"); fs::write(&a_proto, "syntax = 'proto3'; message Apple {}").unwrap(); fs::write( &b_proto, "syntax = 'proto3'; import 'a.proto'; me...
identifier_body
issue-21361.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except accordin...
random_line_split
issue-21361.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let v = vec![1, 2, 3]; let boxed: Box<Iterator<Item=i32>> = Box::new(v.into_iter()); assert_eq!(boxed.max(), Some(3)); let v = vec![1, 2, 3]; let boxed: &mut Iterator<Item=i32> = &mut v.into_iter(); assert_eq!(boxed.max(), Some(3)); }
identifier_body
issue-21361.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let v = vec![1, 2, 3]; let boxed: Box<Iterator<Item=i32>> = Box::new(v.into_iter()); assert_eq!(boxed.max(), Some(3)); let v = vec![1, 2, 3]; let boxed: &mut Iterator<Item=i32> = &mut v.into_iter(); assert_eq!(boxed.max(), Some(3)); }
main
identifier_name
issue-10806.rs
// Copyright 2013-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 _x = baz::quux(); let _y = grault::garply(); let _z = waldo::plugh(); }
identifier_body
issue-10806.rs
// Copyright 2013-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...
() -> int { 3 } pub fn bar() -> int { 4 } pub mod baz { use {foo, bar}; pub fn quux() -> int { foo() + bar() } } pub mod grault { use {foo}; pub fn garply() -> int { foo() } } pub mod waldo { use {}; pub fn plugh() -> int { 0 } } pub fn main() { ...
foo
identifier_name
issue-10806.rs
// Copyright 2013-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 _z = waldo::plugh(); }
pub fn main() { let _x = baz::quux(); let _y = grault::garply();
random_line_split
cef_request_context_handler.rs
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of ...
#![allow(non_snake_case, unused_imports)] use eutil; use interfaces; use types; use wrappers::CefWrap; use libc; use std::collections::HashMap; use std::ptr; // // Implement this structure to provide handler implementations. // #[repr(C)] pub struct _cef_request_context_handler_t { // // Base structure. // p...
random_line_split
cef_request_context_handler.rs
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of ...
unsafe fn to_rust(c_object: *mut cef_request_context_handler_t) -> CefRequestContextHandler { CefRequestContextHandler::from_c_object_addref(c_object) } } impl CefWrap<*mut cef_request_context_handler_t> for Option<CefRequestContextHandler> { fn to_c(rust_object: Option<CefRequestContextHandler>) -> *mut cef...
{ rust_object.c_object_addrefed() }
identifier_body
cef_request_context_handler.rs
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of ...
(&self) -> *mut cef_request_context_handler_t { self.c_object } pub fn c_object_addrefed(&self) -> *mut cef_request_context_handler_t { unsafe { if!self.c_object.is_null() { eutil::add_ref(self.c_object as *mut types::cef_base_t); } self.c_object } } pub fn is_null_cef_ob...
c_object
identifier_name
secret.rs
// Copyright 2015-2017 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 lat...
/// Inplace inverse secret key (1 / scalar) pub fn inv(&mut self) -> Result<(), Error> { let mut key_secret = self.to_secp256k1_secret()?; key_secret.inv_assign(&SECP256K1)?; *self = key_secret.into(); Ok(()) } /// Compute power of secret key inplace (secret ^ pow). /// This function is not intended to...
{ let mut key_secret = self.to_secp256k1_secret()?; key_secret.mul_assign(&SECP256K1, &key::MINUS_ONE_KEY)?; *self = key_secret.into(); Ok(()) }
identifier_body
secret.rs
// Copyright 2015-2017 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 lat...
(&self) -> String { self.inner.to_hex() } } impl fmt::Debug for Secret { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "Secret: 0x{:x}{:x}..{:x}{:x}", self.inner[0], self.inner[1], self.inner[30], self.inner[31]) } } impl Secret { pub fn from_slice(key: &[u8]) -> Self { assert_eq!(32,...
to_hex
identifier_name
secret.rs
// Copyright 2015-2017 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 lat...
/// Inplace decrease secret key (scalar - 1) pub fn dec(&mut self) -> Result<(), Error> { let mut key_secret = self.to_secp256k1_secret()?; key_secret.add_assign(&SECP256K1, &key::MINUS_ONE_KEY)?; *self = key_secret.into(); Ok(()) } /// Inplace multiply one secret key to another (scalar * scalar) pub fn ...
random_line_split
kill.rs
#![crate_name = "uu_kill"] /* * This file is part of the uutils coreutils package. * * (c) Maciej Dziardziel <fiedzia@gmail.com> * * For the full copyright and license information, please view the LICENSE file * that was distributed with this source code. */ extern crate getopts; extern crate libc; #[macro_us...
(signalname: &str, pids: std::vec::Vec<String>) -> i32 { let mut status = 0; let optional_signal_value = uucore::signals::signal_by_name_or_value(signalname); let signal_value = match optional_signal_value { Some(x) => x, None => crash!(EXIT_ERR, "unknown signal name {}", signalname) }; ...
kill
identifier_name
kill.rs
#![crate_name = "uu_kill"] /* * This file is part of the uutils coreutils package. * * (c) Maciej Dziardziel <fiedzia@gmail.com> * * For the full copyright and license information, please view the LICENSE file * that was distributed with this source code. */ extern crate getopts; extern crate libc; #[macro_us...
} fn table() { let mut name_width = 0; /* Compute the maximum width of a signal name. */ for s in &ALL_SIGNALS { if s.name.len() > name_width { name_width = s.name.len() } } for (idx, signal) in ALL_SIGNALS.iter().enumerate() { print!("{0: >#2} {1: <#8}", idx+1...
{ let mut i = 0; while i < args.len() { // this is safe because slice is valid when it is referenced let slice = &args[i].clone(); if slice.chars().next().unwrap() == '-' && slice.len() > 1 && slice.chars().nth(1).unwrap().is_digit(10) { let val = &slice[1..]; mat...
identifier_body