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
glue.rs
let llty = sizing_type_of(ccx, typ); // `Box<ZeroSizeType>` does not allocate. if llsize_of_alloc(ccx, llty) == 0 { tcx.types.i8 } else { t } } _ => t } } pub fn drop_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ...
let unit_size = llsize_of_alloc(bcx.ccx(), llunit_ty); (Mul(bcx, info, C_uint(bcx.ccx(), unit_size), DebugLoc::None), C_uint(bcx.ccx(), unit_align))
random_line_split
glue.rs
trans_exchange_free(bcx, ptr, content_size, content_align, debug_loc) } else { bcx } } pub fn get_drop_glue_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty<'tcx> { let tcx = ccx.tcx(); // Even if there is no dtor for t, there might be o...
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum DropGlueKind<'tcx> { /// The normal path; runs the dtor, and then recurs on the contents Ty(Ty<'tcx>), /// Skips the dtor, if any, for ty; drops the contents directly. /// Note that the dtor is only skipped at the most *shallow* /// level...
{ get_drop_glue_core(ccx, DropGlueKind::Ty(t)) }
identifier_body
lib.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...
_direct: &[(Address, U256)], _indirect: &[(Address, U256)], ) -> Result<(), Self::Error> { Ok(()) } }
&self, _live: &mut Self::LiveBlock,
random_line_split
lib.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, _live: &mut Self::LiveBlock, _direct: &[(Address, U256)], _indirect: &[(Address, U256)], ) -> Result<(), Self::Error> { Ok(()) } }
note_rewards
identifier_name
lib.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...
}
{ Ok(()) }
identifier_body
mod.rs
//! Traits and datastructures representing a collection trace. //! //! A collection trace is a set of updates of the form `(key, val, time, diff)`, which determine the contents //! of a collection at given times by accumulating updates whose time field is less or equal to the target field. //! //! The `Trace` trait des...
else { panic!("unable to acquire complete cursor for trace; is it closed?"); } } /// Acquires a cursor to the restriction of the collection's contents to updates at times not greater or /// equal to an element of `upper`. /// /// This method is expected to work if called with an `upper` that (i) was an ob...
{ cursor }
conditional_block
mod.rs
//! Traits and datastructures representing a collection trace. //! //! A collection trace is a set of updates of the form `(key, val, time, diff)`, which determine the contents //! of a collection at given times by accumulating updates whose time field is less or equal to the target field. //! //! The `Trace` trait des...
pub struct AbomonatedMerger<K,V,T,R,B:Batch<K,V,T,R>> { merger: B::Merger } /// Represents a merge in progress. impl<K,V,T,R,B:Batch<K,V,T,R>+Abomonation> Merger<K, V, T, R, Abomonated<B,Vec<u8>>> for AbomonatedMerger<K,V,T,R,B> { fn new(source1: &Abomonated<B,Vec<u8>>, source2: &Abomonated<B,Vec<u8>>) -> Self { ...
random_line_split
mod.rs
//! Traits and datastructures representing a collection trace. //! //! A collection trace is a set of updates of the form `(key, val, time, diff)`, which determine the contents //! of a collection at given times by accumulating updates whose time field is less or equal to the target field. //! //! The `Trace` trait des...
(&mut self, target: &mut Antichain<Self::Time>) where Self::Time: Timestamp, { target.clear(); target.insert(Default::default()); self.map_batches(|batch| { target.clear(); for time in batch.upper().iter().cloned() { target.insert(time); } }); } /// Advances `upper` by any empty batches. ...
read_upper
identifier_name
mod.rs
//! Traits and datastructures representing a collection trace. //! //! A collection trace is a set of updates of the form `(key, val, time, diff)`, which determine the contents //! of a collection at given times by accumulating updates whose time field is less or equal to the target field. //! //! The `Trace` trait des...
/// All times in the batch are not greater or equal to any element of `upper`. fn upper(&self) -> &[T] { self.description().upper() } } /// An immutable collection of updates. pub trait Batch<K, V, T, R> : BatchReader<K, V, T, R> where Self: ::std::marker::Sized { /// A type used to assemble batches from disordere...
{ self.description().lower() }
identifier_body
dirname.rs
#![crate_name = "uu_dirname"] /* * This file is part of the uutils coreutils package. * * (c) Derek Chiang <derekchiang93@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; use std::path::Path; sta...
(args: Vec<String>) -> i32 { let mut opts = getopts::Options::new(); opts.optflag("z", "zero", "separate output with NUL rather than newline"); opts.optflag("", "help", "display this help and exit"); opts.optflag("", "version", "output version information and exit"); let matches = match opts.parse(...
uumain
identifier_name
dirname.rs
#![crate_name = "uu_dirname"] /* * This file is part of the uutils coreutils package. * * (c) Derek Chiang <derekchiang93@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; use std::path::Path; sta...
println!("{0}: missing operand", NAME); println!("Try '{0} --help' for more information.", NAME); return 1; } 0 }
} } else {
random_line_split
dirname.rs
#![crate_name = "uu_dirname"] /* * This file is part of the uutils coreutils package. * * (c) Derek Chiang <derekchiang93@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; use std::path::Path; sta...
print!("{}", opts.usage(&msg)); return 0; } if matches.opt_present("version") { println!("{} {}", NAME, VERSION); return 0; } let separator = if matches.opt_present("zero") {"\0"} else {"\n"}; if!matches.free.is_empty() { for path in &matches.free { ...
{ let mut opts = getopts::Options::new(); opts.optflag("z", "zero", "separate output with NUL rather than newline"); opts.optflag("", "help", "display this help and exit"); opts.optflag("", "version", "output version information and exit"); let matches = match opts.parse(&args[1..]) { Ok(m)...
identifier_body
error.rs
use common::document::ContainerDocument; use snafu::Snafu; #[derive(Debug, Snafu)] pub enum Error { #[snafu(display("Failed to parse {} document: {}", target_type, source))] Deserialization { target_type: &'static str, source: serde_json::Error, }, #[snafu(display("Document Retrieval Er...
<T: ContainerDocument>(err: serde_json::Error) -> Self { Self::Deserialization { target_type: T::static_doc_type(), source: err, } } }
from_deserialization
identifier_name
error.rs
use common::document::ContainerDocument; use snafu::Snafu; #[derive(Debug, Snafu)] pub enum Error { #[snafu(display("Failed to parse {} document: {}", target_type, source))] Deserialization { target_type: &'static str, source: serde_json::Error, }, #[snafu(display("Document Retrieval Er...
#[snafu(display("Status Error: {}", source))] Status { source: Box<dyn std::error::Error> }, #[snafu(display("Backend Configuration Error: {}", source))] BackendConfiguration { source: Box<dyn std::error::Error> }, } impl Error { pub fn from_deserialization<T: ContainerDocument>(err: serde_json::E...
#[snafu(display("Configuration Error: {}", source))] Configuration { source: config::ConfigError },
random_line_split
is_integer.rs
use integer::Integer; use malachite_base::num::conversion::traits::IsInteger; impl<'a> IsInteger for &'a Integer { /// Determines whether an `Integer` is an integer. It always returns `true`. /// /// $f(x) = \textrm{true}$. /// /// # Worst-case complexity /// Constant time and additional memory...
/// extern crate malachite_base; /// extern crate malachite_nz; /// /// use malachite_base::num::basic::traits::{NegativeOne, One, Zero}; /// use malachite_base::num::conversion::traits::IsInteger; /// use malachite_nz::integer::Integer; /// /// assert_eq!(Integer::ZERO.is_integer(), tru...
/// # Examples /// ```
random_line_split
is_integer.rs
use integer::Integer; use malachite_base::num::conversion::traits::IsInteger; impl<'a> IsInteger for &'a Integer { /// Determines whether an `Integer` is an integer. It always returns `true`. /// /// $f(x) = \textrm{true}$. /// /// # Worst-case complexity /// Constant time and additional memory...
(self) -> bool { true } }
is_integer
identifier_name
is_integer.rs
use integer::Integer; use malachite_base::num::conversion::traits::IsInteger; impl<'a> IsInteger for &'a Integer { /// Determines whether an `Integer` is an integer. It always returns `true`. /// /// $f(x) = \textrm{true}$. /// /// # Worst-case complexity /// Constant time and additional memory...
}
{ true }
identifier_body
view.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
self.core.begin_outro_scene(); action = action.and_return(PuzzleCmd::Save); } action.also_redraw(); } } if (!action.should_stop() && self.remove_countdown == 0) || event == &Event::ClockTick { ...
{ let state = &mut game.if_memory_serves; let mut action = self.core.handle_event(event, state); if event == &Event::ClockTick && self.remove_countdown > 0 { self.remove_countdown -= 1; if self.remove_countdown == REMOVE_SOUND_AT { let symbol = self.grid.f...
identifier_body
view.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
if (!action.should_stop() && self.remove_countdown == 0) || event == &Event::ClockTick { let subaction = self.grid.handle_event(event, state.grid_mut()); if let Some(&symbol) = subaction.value() { action.also_play_sound(Sound::device_rotate()); ...
{ let subaction = self.next.handle_event(event, &mut state.next_shape()); if let Some(&pt) = subaction.value() { let (col, row) = self.grid.coords_for_point(pt); if let Some(symbol) = state.try_place_shape(col, row) { action.als...
conditional_block
view.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
(&mut self, _: &mut Game) {} fn redo(&mut self, _: &mut Game) {} fn reset(&mut self, game: &mut Game) { self.core.clear_undo_redo(); game.if_memory_serves.reset(); } fn solve(&mut self, game: &mut Game) { game.if_memory_serves.solve(); self.core.begin_outro_scene(); ...
undo
identifier_name
view.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
if value >= 0 && (value as usize) < LETTERS.len() { let (col, row, letter) = LETTERS[value as usize]; self.grid.add_letter(col, row, letter); } } } } } // ====================================================================...
if kind == 0 { self.show_next = value != 0; } else if kind == 1 {
random_line_split
srgb.rs
// Copyright 2013 The color-rs developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.
// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the Licen...
// You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0
random_line_split
srgb.rs
// Copyright 2013 The color-rs developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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 o...
}
{ Srgb { r: r, g: g, b: b } }
identifier_body
srgb.rs
// Copyright 2013 The color-rs developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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 o...
<T> { pub r: T, pub g: T, pub b: T } impl<T> Srgb<T> { #[inline] pub fn new(r: T, g: T, b: T) -> Srgb<T> { Srgb { r: r, g: g, b: b } } }
Srgb
identifier_name
scene.rs
// Robigo Luculenta -- Proof of concept spectral path tracer in Rust // Copyright (C) 2014-2015 Ruud van Asseldonk // // This program 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 L...
(&self, ray: &Ray) -> Option<(Intersection, &Object)> { // Assume Nothing is found, and that Nothing is Very Far Away (tm). let mut result = None; let mut distance = 1.0e12f32; // Then intersect all surfaces. for obj in &self.objects { match obj.surface.intersect(ray...
intersect
identifier_name
scene.rs
// Robigo Luculenta -- Proof of concept spectral path tracer in Rust // Copyright (C) 2014-2015 Ruud van Asseldonk // // This program 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 L...
// TODO: apparently there is no such thing as an immutable closure // any more, but I'd prefer to be able to use a pure function here, // which might be a closure. pub get_camera_at_time: fn (f32) -> Camera } impl Scene { /// Intersects the specified ray with the scene. pub fn intersect(&self, ...
/// A function that returns the camera through which the scene /// will be seen. The function takes one parameter, the time (in /// the range 0.0 - 1.0), which will be sampled randomly to create /// effects like motion blur and zoom blur.
random_line_split
scene.rs
// Robigo Luculenta -- Proof of concept spectral path tracer in Rust // Copyright (C) 2014-2015 Ruud van Asseldonk // // This program 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 L...
} } } result } }
{ result = Some((isect, obj)); distance = isect.distance; }
conditional_block
annotateable.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library 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 ...
<'a>(&self, store: &'a Store) -> Result<AnnotationIter<'a>> { self.get_internal_links() .map_err(From::from) .map(|iter| StoreIdIterator::new(Box::new(iter.map(|e| e.get_store_id().clone())))) .map(|i| AnnotationIter::new(i, store)) } fn is_annotation(&self) -> Result<b...
annotations
identifier_name
annotateable.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library 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 ...
fn is_annotation(&self) -> Result<bool> { self.is::<IsAnnotation>().map_err(From::from) } }
{ self.get_internal_links() .map_err(From::from) .map(|iter| StoreIdIterator::new(Box::new(iter.map(|e| e.get_store_id().clone())))) .map(|i| AnnotationIter::new(i, store)) }
identifier_body
annotateable.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library 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 ...
{ let _ = anno.set_isflag::<IsAnnotation>()?; let _ = anno .get_header_mut() .insert("annotation.name", Value::String(String::from(ann_name)))?; } Ok(anno) }) .and...
fn annotate<'a>(&mut self, store: &'a Store, ann_name: &str) -> Result<FileLockEntry<'a>> { use module_path::ModuleEntryPath; store.retrieve(ModuleEntryPath::new(ann_name).into_storeid()?) .map_err(From::from) .and_then(|mut anno| {
random_line_split
textdecoder.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::TextDecoderBinding; use dom::bindings::codegen::Bindings::TextDecoderBinding...
#[allow(unsafe_code)] fn Decode(self, _cx: *mut JSContext, input: Option<*mut JSObject>) -> Fallible<USVString> { let input = match input { Some(input) => input, None => return Ok(USVString("".to_owned())), }; let mut length = 0; let mut d...
{ self.fatal }
identifier_body
textdecoder.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::TextDecoderBinding; use dom::bindings::codegen::Bindings::TextDecoderBinding...
(encoding: EncodingRef, fatal: bool) -> TextDecoder { TextDecoder { reflector_: Reflector::new(), encoding: encoding, fatal: fatal, } } fn make_range_error() -> Fallible<Root<TextDecoder>> { Err(Error::Range("The given encoding is not supported.".to_o...
new_inherited
identifier_name
textdecoder.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::TextDecoderBinding; use dom::bindings::codegen::Bindings::TextDecoderBinding...
} }
match self.encoding.decode(buffer, trap) { Ok(s) => Ok(USVString(s)), Err(_) => Err(Error::Type("Decoding failed".to_owned())), }
random_line_split
cap-clause-move.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let x = ~3; let y = ptr::to_unsafe_ptr(&(*x)) as uint; let snd_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint; assert_eq!(snd_move(), y); let x = ~4; let y = ptr::to_unsafe_ptr(&(*x)) as uint; let lam_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint; assert_eq!(l...
identifier_body
cap-clause-move.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let x = ~3; let y = ptr::to_unsafe_ptr(&(*x)) as uint; let snd_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint; assert_eq!(snd_move(), y); let x = ~4; let y = ptr::to_unsafe_ptr(&(*x)) as uint; let lam_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint; assert_eq...
main
identifier_name
cap-clause-move.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::ptr; pub fn main() { let x = ~3; let y = ptr::to_unsafe_ptr(&(*x)) as uint; let snd_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x...
random_line_split
account.rs
// droplet_limit number The total number of droplets the user may have // email string The email the user has registered for Digital // Ocean with // uuid string The universal identifier for this user // email_verified boolean If true, the user has verified their account /...
pub uuid: String, pub email_verified: bool, } impl NotArray for Account {} impl fmt::Display for Account { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Email: {}\n\ Droplet Limit: {:.0}\n\ UUID: {}\n\ E-Ma...
pub droplet_limit: f64, pub email: String,
random_line_split
account.rs
// droplet_limit number The total number of droplets the user may have // email string The email the user has registered for Digital // Ocean with // uuid string The universal identifier for this user // email_verified boolean If true, the user has verified their account /...
} // TODO: Implement response headers: // content-type: application/json; charset=utf-8 // status: 200 OK // ratelimit-limit: 1200 // ratelimit-remaining: 1137 // ratelimit-reset: 1415984218
{ "account".into() }
identifier_body
account.rs
// droplet_limit number The total number of droplets the user may have // email string The email the user has registered for Digital // Ocean with // uuid string The universal identifier for this user // email_verified boolean If true, the user has verified their account /...
<'a>() -> Cow<'a, str> { "account".into() } } // TODO: Implement response headers: // content-type: application/json; charset=utf-8 // status: 200 OK // ratelimit-limit: 1200 // ratelimit-remaining: 1137 // ratelimit-reset: 1415984218
name
identifier_name
state_script.rs
use crate::state::*; use std; use std::process::Command; struct StateScript { script_path: String, shared_state: SharedState, state_observer: StateObserver, } impl StateScript { fn new(script_path: &str, shared_state: SharedState) -> StateScript { let state_observer = shared_state.lock().add_o...
fn run(&mut self) { let mut stream_state; let mut output_name: String; { let state = self.shared_state.lock(); output_name = state.current_output().name.clone(); stream_state = state.state().stream_state; }; self.run_script(stream_state, ...
{ let result = Command::new(&self.script_path) .arg(state.as_str()) .arg(output) .status(); match result { Ok(status) => { if !status.success() { println!( "ERROR: {} {} failed with error code {}"...
identifier_body
state_script.rs
use crate::state::*; use std; use std::process::Command; struct StateScript { script_path: String, shared_state: SharedState, state_observer: StateObserver, } impl StateScript { fn
(script_path: &str, shared_state: SharedState) -> StateScript { let state_observer = shared_state.lock().add_observer(); StateScript { script_path: String::from(script_path), shared_state, state_observer, } } fn run_script(&self, state: StreamState, o...
new
identifier_name
state_script.rs
use crate::state::*; use std; use std::process::Command; struct StateScript { script_path: String, shared_state: SharedState, state_observer: StateObserver, } impl StateScript { fn new(script_path: &str, shared_state: SharedState) -> StateScript { let state_observer = shared_state.lock().add_o...
state.as_str(), status.code().unwrap_or(0) ); } } Err(e) => println!("ERROR: Failed to run {}: {}", self.script_path, e), } } fn run(&mut self) { let mut stream_state; let mut out...
"ERROR: {} {} failed with error code {}", self.script_path,
random_line_split
remote.rs
use std::cell::{RefCell, Ref, Cell}; use std::io::SeekFrom; use std::io::prelude::*; use std::mem; use std::path::Path; use curl::easy::{Easy, List}; use git2; use hex::ToHex; use serde_json; use url::Url; use core::{PackageId, SourceId}; use ops; use sources::git; use sources::registry::{RegistryData, RegistryConfig...
(&self) -> CargoResult<&git2::Repository> { self.repo.get_or_try_init(|| { let path = self.index_path.clone().into_path_unlocked(); // Fast path without a lock if let Ok(repo) = git2::Repository::open(&path) { return Ok(repo) } // Ok,...
repo
identifier_name
remote.rs
use std::cell::{RefCell, Ref, Cell}; use std::io::SeekFrom; use std::io::prelude::*; use std::mem; use std::path::Path; use curl::easy::{Easy, List}; use git2; use hex::ToHex; use serde_json; use url::Url; use core::{PackageId, SourceId}; use ops; use sources::git; use sources::registry::{RegistryData, RegistryConfig...
debug!("attempting github fast path for {}", self.source_id.url()); if github_up_to_date(&mut handle, self.source_id.url(), &oid) { needs_fetch = false; } else { debug!("fast path failed, falling back to a git...
{ // Ensure that we'll actually be able to acquire an HTTP handle later on // once we start trying to download crates. This will weed out any // problems with `.cargo/config` configuration related to HTTP. // // This way if there's a problem the error gets printed before we even ...
identifier_body
remote.rs
use std::cell::{RefCell, Ref, Cell}; use std::io::SeekFrom; use std::io::prelude::*; use std::mem; use std::path::Path; use curl::easy::{Easy, List}; use git2; use hex::ToHex; use serde_json; use url::Url; use core::{PackageId, SourceId}; use ops; use sources::git; use sources::registry::{RegistryData, RegistryConfig...
let repo = self.repo()?; let _lock = self.index_path.open_rw(Path::new(INDEX_LOCK), self.config, "the registry index")?; self.config.shell().status("Updating", format!("registry `{}`", self.sour...
ops::http_handle(self.config)?;
random_line_split
remote.rs
use std::cell::{RefCell, Ref, Cell}; use std::io::SeekFrom; use std::io::prelude::*; use std::mem; use std::path::Path; use curl::easy::{Easy, List}; use git2; use hex::ToHex; use serde_json; use url::Url; use core::{PackageId, SourceId}; use ops; use sources::git; use sources::registry::{RegistryData, RegistryConfig...
} } if needs_fetch { // git fetch origin master let url = self.source_id.url().to_string(); let refspec = "refs/heads/master:refs/remotes/origin/master"; git::fetch(&repo, &url, refspec, self.config).chain_err(|| { format!("fa...
{ debug!("fast path failed, falling back to a git fetch"); }
conditional_block
inline-closure.rs
// Copyright 2017 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 ...
// END RUST SOURCE // START rustc.foo.Inline.after.mir //... // bb0: { // ... // _3 = [closure@NodeId(39)]; // ... // _4 = &_3; // ... // _6 = _2; // ... // _7 = _2; // _5 = (move _6, move _7); // _8 = move (_5.0: i32); // _9 = move (_5.1: i32); // _0 = _8; // ... // ...
{ let x = |_t, _q| _t; x(q, q) }
identifier_body
inline-closure.rs
// Copyright 2017 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 ...
() { println!("{}", foo(0, 14)); } fn foo<T: Copy>(_t: T, q: i32) -> i32 { let x = |_t, _q| _t; x(q, q) } // END RUST SOURCE // START rustc.foo.Inline.after.mir //... // bb0: { // ... // _3 = [closure@NodeId(39)]; // ... // _4 = &_3; // ... // _6 = _2; // ... // _7 = _2; // ...
main
identifier_name
inline-closure.rs
// Copyright 2017 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(q, q) } // END RUST SOURCE // START rustc.foo.Inline.after.mir //... // bb0: { // ... // _3 = [closure@NodeId(39)]; // ... // _4 = &_3; // ... // _6 = _2; // ... // _7 = _2; // _5 = (move _6, move _7); // _8 = move (_5.0: i32); // _9 = move (_5.1: i32); // _0 = _8; // ...
random_line_split
lib.rs
#![crate_name="otp"] #![crate_type="lib"] use std::time::{SystemTime, SystemTimeError}; use std::convert::TryInto; use data_encoding::{BASE32_NOPAD, DecodeError}; use err_derive::Error; use ring::hmac; #[derive(Debug, Error)] pub enum Error { #[error(display="invalid time provided")] InvalidTimeError(#[error(...
/// Performs the [HMAC-based One-time Password Algorithm](http://en.wikipedia.org/wiki/HMAC-based_One-time_Password_Algorithm) /// (HOTP) given an RFC4648 base32 encoded secret, and an integer counter. pub fn make_hotp(secret: &str, counter: u64) -> Result<u32, Error> { let decoded = decode_secret(secret)?; e...
{ let offset = match digest.last() { Some(x) => *x & 0xf, None => return Err(Error::InvalidDigest(Vec::from(digest))) } as usize; let code_bytes: [u8; 4] = match digest[offset..offset+4].try_into() { Ok(x) => x, Err(_) => return Err(Error::InvalidDigest(Vec::from(digest))) ...
identifier_body
lib.rs
#![crate_name="otp"] #![crate_type="lib"] use std::time::{SystemTime, SystemTimeError}; use std::convert::TryInto; use data_encoding::{BASE32_NOPAD, DecodeError}; use err_derive::Error; use ring::hmac; #[derive(Debug, Error)] pub enum Error { #[error(display="invalid time provided")] InvalidTimeError(#[error(...
(secret: &str, time_step: u64, skew: i64, time: u64) -> Result<u32, Error> { let counter = ((time as i64 + skew) as u64) / time_step; make_hotp(secret, counter) } /// Performs the [Time-based One-time Password Algorithm](http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm) /// (TOTP) given an R...
make_totp_helper
identifier_name
lib.rs
#![crate_name="otp"] #![crate_type="lib"] use std::time::{SystemTime, SystemTimeError}; use std::convert::TryInto; use data_encoding::{BASE32_NOPAD, DecodeError}; use err_derive::Error; use ring::hmac; #[derive(Debug, Error)] pub enum Error { #[error(display="invalid time provided")] InvalidTimeError(#[error(...
assert_eq!(make_totp_helper("BASE32SECRET3232", 1, -2, 1403).unwrap(), 316439); } }
assert_eq!(make_totp_helper("BASE32SECRET3232", 3600, 0, 7).unwrap(), 260182); assert_eq!(make_totp_helper("BASE32SECRET3232", 30, 0, 35).unwrap(), 55283);
random_line_split
util.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.com> // // 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, modifi...
let mut parts = [0u8; 6]; let splits = s.split(':'); let mut i = 0; for split in splits { if i == 6 { return Err(ParseMacAddrErr::TooManyComponents); } match u8::from_str_radix(split, 16) { Ok(b) if split.len()!= 0 => pa...
random_line_split
util.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.com> // // 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, modifi...
(a: u8, b: u8, c: u8, d: u8, e: u8, f: u8) -> MacAddr { MacAddr(a, b, c, d, e, f) } } impl PrimitiveValues for MacAddr { type T = (u8, u8, u8, u8, u8, u8); fn to_primitive_values(&self) -> (u8, u8, u8, u8, u8, u8) { (self.0, self.1, self.2, self.3, self.4, self.5) } } impl fmt::Display...
new
identifier_name
util.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.com> // // 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, modifi...
else { let addr = internal::sockaddr_to_addr(mem::transmute(sa), mem::size_of::<libc::sockaddr_storage>()); match addr { Ok(sa) => (None, Some(sa.ip())), Err(_) => (None, None), } } } } #...
{ let sll: *const libc::sockaddr_ll = mem::transmute(sa); let mac = MacAddr((*sll).sll_addr[0], (*sll).sll_addr[1], (*sll).sll_addr[2], (*sll).sll_addr[3], (*sll).sll_addr[4], ...
conditional_block
util.rs
// Copyright (c) 2014, 2015 Robert Clipsham <robert@octarineparrot.com> // // 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, modifi...
} impl fmt::Display for MacAddr { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "{:x}:{:x}:{:x}:{:x}:{:x}:{:x}", self.0, self.1, self.2, self.3, self.4, self.5) } } impl fmt...
{ (self.0, self.1, self.2, self.3, self.4, self.5) }
identifier_body
forget_room.rs
//! `POST /_matrix/client/*/rooms/{roomId}/forget` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3roomsroomidforget use ruma_common::{api::ruma_api, RoomId}; ruma_api! { metadata: { description: "Forget a roo...
() -> Self { Self {} } } }
new
identifier_name
forget_room.rs
//! `POST /_matrix/client/*/rooms/{roomId}/forget` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3roomsroomidforget use ruma_common::{api::ruma_api, RoomId}; ruma_api! { metadata: { description: "Forget a roo...
} }
{ Self {} }
identifier_body
forget_room.rs
//! `POST /_matrix/client/*/rooms/{roomId}/forget` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3roomsroomidforget use ruma_common::{api::ruma_api, RoomId}; ruma_api! { metadata: { description: "Forget a roo...
}
random_line_split
mod.rs
// SPDX-License-Identifier: MIT // Copyright wtfsckgh@gmail.com // Copyright iced contributors use super::super::test_utils::*; use super::super::*; use alloc::vec::Vec; use core::cmp::Ordering; use core::u32; mod br8_16; mod br8_32; mod br8_64; mod call_16; mod call_32; mod call_64; mod ip_rel_64; mod jcc_16; mod jc...
(bitness: u32, rip: u64, data: &[u8], options: u32) -> Vec<Instruction> { let mut decoder = create_decoder(bitness, data, options).0; decoder.set_ip(rip); decoder.into_iter().collect() } fn sort(mut vec: Vec<RelocInfo>) -> Vec<RelocInfo> { vec.sort_unstable_by(|a, b| { let c = a.address.cmp(&b.address); if c!=...
decode
identifier_name
mod.rs
// SPDX-License-Identifier: MIT // Copyright wtfsckgh@gmail.com // Copyright iced contributors use super::super::test_utils::*; use super::super::*; use alloc::vec::Vec; use core::cmp::Ordering; use core::u32; mod br8_16; mod br8_32; mod br8_64; mod call_16; mod call_32; mod call_64; mod ip_rel_64; mod jcc_16; mod jc...
} } assert_eq!(constant_offsets, expected_constant_offsets); }
decoder.set_ip(new_rip.wrapping_add(offset as u64)); decoder.decode_out(&mut instr); expected_constant_offsets.push(decoder.get_constant_offsets(&instr));
random_line_split
mod.rs
// SPDX-License-Identifier: MIT // Copyright wtfsckgh@gmail.com // Copyright iced contributors use super::super::test_utils::*; use super::super::*; use alloc::vec::Vec; use core::cmp::Ordering; use core::u32; mod br8_16; mod br8_32; mod br8_64; mod call_16; mod call_32; mod call_64; mod ip_rel_64; mod jcc_16; mod jc...
#[allow(clippy::too_many_arguments)] fn encode_test( bitness: u32, orig_rip: u64, original_data: &[u8], new_rip: u64, new_data: &[u8], mut options: u32, decoder_options: u32, expected_instruction_offsets: &[u32], expected_reloc_infos: &[RelocInfo], ) { let orig_instrs = decode(bitness, orig_rip, original_data, dec...
{ vec.sort_unstable_by(|a, b| { let c = a.address.cmp(&b.address); if c != Ordering::Equal { c } else { a.kind.cmp(&b.kind) } }); vec }
identifier_body
mod.rs
// SPDX-License-Identifier: MIT // Copyright wtfsckgh@gmail.com // Copyright iced contributors use super::super::test_utils::*; use super::super::*; use alloc::vec::Vec; use core::cmp::Ordering; use core::u32; mod br8_16; mod br8_32; mod br8_64; mod call_16; mod call_32; mod call_64; mod ip_rel_64; mod jcc_16; mod jc...
else { a.kind.cmp(&b.kind) } }); vec } #[allow(clippy::too_many_arguments)] fn encode_test( bitness: u32, orig_rip: u64, original_data: &[u8], new_rip: u64, new_data: &[u8], mut options: u32, decoder_options: u32, expected_instruction_offsets: &[u32], expected_reloc_infos: &[RelocInfo], ) { let orig_instrs ...
{ c }
conditional_block
macro_crate_test.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...
// Most of this is modelled after the expansion of the `quote_expr!` // macro... let parse_sess = cx.parse_sess(); let cfg = cx.cfg(); //... except this is where we inject a forged identifier, // and deliberately do not call `cx.parse_tts_with_hygiene` // (because we are testing that this...
{ cx.span_fatal(sp, "forged_ident takes no arguments"); }
conditional_block
macro_crate_test.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...
} // See Issue #15750 fn expand_identity(cx: &mut ExtCtxt, _span: Span, tts: &[TokenTree]) -> Box<MacResult+'static> { // Parse an expression and emit it unchanged. let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_vec()); let expr = parser.parse_expr(...
if !tts.is_empty() { cx.span_fatal(sp, "make_a_1 takes no arguments"); } MacExpr::new(quote_expr!(cx, 1i))
random_line_split
macro_crate_test.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...
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: &MetaItem, it: P<Item>) -> P<Item> { P(Item { attrs: it.attrs.clone(), ..(*quote_item!(cx, enum Foo { Bar, Baz }).unwrap()).clone() }) } fn expand_forged_ident(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResul...
{ // Parse an expression and emit it unchanged. let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_vec()); let expr = parser.parse_expr(); MacExpr::new(quote_expr!(&mut *cx, $expr)) }
identifier_body
macro_crate_test.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...
(reg: &mut Registry) { reg.register_macro("make_a_1", expand_make_a_1); reg.register_macro("forged_ident", expand_forged_ident); reg.register_macro("identity", expand_identity); reg.register_syntax_extension( token::intern("into_foo"), Modifier(box expand_into_foo)); } fn expand_make_a_...
plugin_registrar
identifier_name
shadows.rs
/* * Copyright (C) 2012 The Android Open Source Project * * 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 app...
} void shadowsKernel(const uchar4 *in, uchar4 *out) { ushort3 hsv = rgb2hsv(*in); double v = (fastevalPoly(poly,5,hsv.x/4080.)*4080); if (v>4080) v = 4080; hsv.x = (unsigned short) ((v>0)?v:0); *out = hsv2rgb(hsv); }
}
random_line_split
shadows.rs
/* * Copyright (C) 2012 The Android Open Source Project * * 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 app...
case 1: rr = X; rg = cv; rb = m; break; case 2: rr = m; rg = cv; rb = X; break; case 3: rr = m; rg = X; rb = cv; break; case 4: rr =...
{ ih=(int)ch; is=(int)cs; iv=(int)cv; H = (6*ih)/k2; X = ((iv*is)/k2)*(k2- abs(6*ih- 2*(H>>1)*k2 - k2)) ; // removing additional bits --> unit8 X=( (X+iv*(k1 - is ))/k1 + k3 ) >> ABITS; m=m >> ABITS; // ( chroma + m ) --> cv ; cv=(short)...
conditional_block
main.rs
#![feature(iter_arith)] use std::io::Read; use std::fs::File; fn main()
}, _ => { index += 1; chars_in_memory += 1; } } }, _ => { chars_in_memory += 1; index += 1; ...
{ let mut f = File::open("../input.txt").unwrap(); let mut s = String::new(); f.read_to_string(&mut s).ok(); let s = s; let answer: i32 = s.lines().map(|x| { let char_num = x.len() as i32; let mut chars_in_memory = 0; let mut index = 1; let chars = x.chars().collect...
identifier_body
main.rs
#![feature(iter_arith)] use std::io::Read; use std::fs::File; fn
() { let mut f = File::open("../input.txt").unwrap(); let mut s = String::new(); f.read_to_string(&mut s).ok(); let s = s; let answer: i32 = s.lines().map(|x| { let char_num = x.len() as i32; let mut chars_in_memory = 0; let mut index = 1; let chars = x.chars().coll...
main
identifier_name
main.rs
#![feature(iter_arith)] use std::io::Read; use std::fs::File; fn main() { let mut f = File::open("../input.txt").unwrap(); let mut s = String::new(); f.read_to_string(&mut s).ok(); let s = s; let answer: i32 = s.lines().map(|x| { let char_num = x.len() as i32; let mut chars_in_me...
index += 3; chars_in_memory += 1; }, _ => { index += 1; chars_in_memory += 1; } } }, ...
index += 1; match chars[index] { 'x' => {
random_line_split
convert_seconds_to_compound_duration.rs
// http://rosettacode.org/wiki/Convert_seconds_to_compound_duration fn seconds_to_compound(secs: u32) -> String { let part = |comps: &mut String, c: &str, one: u32, secs: &mut u32| { if *secs >= one
}; let mut secs = secs; let mut comps = String::new(); part(&mut comps, " wk", 60 * 60 * 24 * 7, &mut secs); part(&mut comps, " d", 60 * 60 * 24, &mut secs); part(&mut comps, " hr", 60 * 60, &mut secs); part(&mut comps, " min", 60, &mut secs); part(&mut comps, " sec", 1, &mut secs); ...
{ let div = *secs / one; comps.push_str(&(div.to_string() + c)); *secs -= one * div; if *secs > 0 { comps.push_str(", "); } }
conditional_block
convert_seconds_to_compound_duration.rs
// http://rosettacode.org/wiki/Convert_seconds_to_compound_duration fn seconds_to_compound(secs: u32) -> String { let part = |comps: &mut String, c: &str, one: u32, secs: &mut u32| { if *secs >= one { let div = *secs / one; comps.push_str(&(div.to_string() + c)); *secs -...
{ println!("7,259 seconds = {}", seconds_to_compound(7259)); println!("86,400 seconds = {}", seconds_to_compound(86400)); println!("6,000,000 seconds = {}", seconds_to_compound(6000000)); }
identifier_body
convert_seconds_to_compound_duration.rs
// http://rosettacode.org/wiki/Convert_seconds_to_compound_duration fn seconds_to_compound(secs: u32) -> String { let part = |comps: &mut String, c: &str, one: u32, secs: &mut u32| { if *secs >= one { let div = *secs / one; comps.push_str(&(div.to_string() + c)); *secs -...
() { assert_eq!(seconds_to_compound(7259), "2 hr, 59 sec"); } #[test] fn one_day() { assert_eq!(seconds_to_compound(86400), "1 d"); } #[test] fn six_million_seconds() { assert_eq!(seconds_to_compound(6000000), "9 wk, 6 d, 10 hr, 40 min"); } fn main() { println!("7,259 seconds = {}", seconds_to_compou...
hours_and_seconds
identifier_name
convert_seconds_to_compound_duration.rs
// http://rosettacode.org/wiki/Convert_seconds_to_compound_duration fn seconds_to_compound(secs: u32) -> String { let part = |comps: &mut String, c: &str, one: u32, secs: &mut u32| {
let div = *secs / one; comps.push_str(&(div.to_string() + c)); *secs -= one * div; if *secs > 0 { comps.push_str(", "); } } }; let mut secs = secs; let mut comps = String::new(); part(&mut comps, " wk", 60 * 60 * 24 * 7...
if *secs >= one {
random_line_split
pm.rs
use core::marker::PhantomData; use volatile::*; #[repr(C, packed)] pub struct PowerManager { pub control: ReadWrite<u8>, // Offset: 0x00 (R/W 8) Control pub sleep: ReadWrite<u8>, // Offset: 0x01 (R/W 8) Sleep Mode pub external_control: ReadWrite<u8>, // Offset: 0x02 (R/W 8) External ...
} }
random_line_split
pm.rs
use core::marker::PhantomData; use volatile::*; #[repr(C, packed)] pub struct
{ pub control: ReadWrite<u8>, // Offset: 0x00 (R/W 8) Control pub sleep: ReadWrite<u8>, // Offset: 0x01 (R/W 8) Sleep Mode pub external_control: ReadWrite<u8>, // Offset: 0x02 (R/W 8) External Reset Controller reserved_1: [u8; 5], pub cpu_select: ReadWrite<u8>, // Offse...
PowerManager
identifier_name
pm.rs
use core::marker::PhantomData; use volatile::*; #[repr(C, packed)] pub struct PowerManager { pub control: ReadWrite<u8>, // Offset: 0x00 (R/W 8) Control pub sleep: ReadWrite<u8>, // Offset: 0x01 (R/W 8) Sleep Mode pub external_control: ReadWrite<u8>, // Offset: 0x02 (R/W 8) External ...
}
{ // Now that all system clocks are configured, we can set CPU and APBx BUS clocks. // There[sic] values are normally the one present after Reset. let PM_CPUSEL_CPUDIV_POS = 0; // (PM_CPUSEL) CPU Prescaler Selection let PM_CPUSEL_CPUDIV_DIV1_VAL = 0x0; // (PM_CPUSEL) Divide by 1 ...
identifier_body
write.rs
use std::fmt; use std::io; pub trait AnyWrite { type wstr:?Sized; type Error; fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error>; fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error>; } impl<'a> AnyWrite for fmt::Write + 'a { type wstr = str; type Error =...
}
{ io::Write::write_all(self, s) }
identifier_body
write.rs
use std::fmt; use std::io; pub trait AnyWrite { type wstr:?Sized; type Error; fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error>; fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error>; } impl<'a> AnyWrite for fmt::Write + 'a { type wstr = str; type Error =...
(&mut self, s: &Self::wstr) -> Result<(), Self::Error> { fmt::Write::write_str(self, s) } } impl<'a> AnyWrite for io::Write + 'a { type wstr = [u8]; type Error = io::Error; fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error> { io::Write::write_fmt(self, fmt) } ...
write_str
identifier_name
write.rs
use std::fmt; use std::io; pub trait AnyWrite { type wstr:?Sized; type Error; fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error>; fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error>; } impl<'a> AnyWrite for fmt::Write + 'a { type wstr = str; type Error =...
fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error> { io::Write::write_all(self, s) } }
random_line_split
scopemeasure_stopover_adds_an_extra_line_to_the_log_upon_each_call.rs
use libnewsboat::{ logger::{self, Level}, scopemeasure::ScopeMeasure, }; use std::fs::File; use std::io::{BufRead, BufReader, Result}; use std::path::Path; use tempfile::TempDir; fn file_lines_count(logfile: &Path) -> Result<usize> { let file = File::open(logfile)?; let reader = BufReader::new(file); ...
assert_eq!(file_lines_count(&logfile).unwrap(), calls + 1usize); } }
{ for calls in &[1, 2, 5] { let tmp = TempDir::new().unwrap(); let logfile = { let mut logfile = tmp.path().to_owned(); logfile.push("example.log"); logfile }; { logger::get_instance().set_logfile(logfile.to_str().unwrap()); ...
identifier_body
scopemeasure_stopover_adds_an_extra_line_to_the_log_upon_each_call.rs
use libnewsboat::{ logger::{self, Level}, scopemeasure::ScopeMeasure, }; use std::fs::File; use std::io::{BufRead, BufReader, Result}; use std::path::Path; use tempfile::TempDir; fn
(logfile: &Path) -> Result<usize> { let file = File::open(logfile)?; let reader = BufReader::new(file); Ok(reader.lines().count()) } #[test] fn stopover_adds_an_extra_line_to_the_log_upon_each_call() { for calls in &[1, 2, 5] { let tmp = TempDir::new().unwrap(); let logfile = { ...
file_lines_count
identifier_name
scopemeasure_stopover_adds_an_extra_line_to_the_log_upon_each_call.rs
use libnewsboat::{ logger::{self, Level}, scopemeasure::ScopeMeasure, }; use std::fs::File; use std::io::{BufRead, BufReader, Result}; use std::path::Path; use tempfile::TempDir; fn file_lines_count(logfile: &Path) -> Result<usize> { let file = File::open(logfile)?; let reader = BufReader::new(file); ...
for calls in &[1, 2, 5] { let tmp = TempDir::new().unwrap(); let logfile = { let mut logfile = tmp.path().to_owned(); logfile.push("example.log"); logfile }; { logger::get_instance().set_logfile(logfile.to_str().unwrap()); ...
#[test] fn stopover_adds_an_extra_line_to_the_log_upon_each_call() {
random_line_split
mod.rs
use std::time::{Instant, Duration}; use super::Figure; /// This struct is responsible for logging the average frame duration to stdout /// once a second. pub struct FpsLog { last_second: Instant, avg_duration_ns: u64, ticks: u64, } impl FpsLog { pub fn new() -> FpsLog { FpsLog { la...
/// Dump the frame time to std out fn print(&self) { let frame_time_ms = self.avg_duration_ns / 1000000; println!("avg frame time: {}ns which is {}ms", self.avg_duration_ns, frame_time_ms); } /// Reset internal state which is used to calculate frame duration fn rese...
avg_duration_ns: 0, ticks: 0 } }
random_line_split
mod.rs
use std::time::{Instant, Duration}; use super::Figure; /// This struct is responsible for logging the average frame duration to stdout /// once a second. pub struct FpsLog { last_second: Instant, avg_duration_ns: u64, ticks: u64, } impl FpsLog { pub fn new() -> FpsLog { FpsLog { la...
(&self) { let frame_time_ms = self.avg_duration_ns / 1000000; println!("avg frame time: {}ns which is {}ms", self.avg_duration_ns, frame_time_ms); } /// Reset internal state which is used to calculate frame duration fn reset(&mut self) { self.last_second = Instant::...
print
identifier_name
mod.rs
use std::time::{Instant, Duration}; use super::Figure; /// This struct is responsible for logging the average frame duration to stdout /// once a second. pub struct FpsLog { last_second: Instant, avg_duration_ns: u64, ticks: u64, } impl FpsLog { pub fn new() -> FpsLog
/// Dump the frame time to std out fn print(&self) { let frame_time_ms = self.avg_duration_ns / 1000000; println!("avg frame time: {}ns which is {}ms", self.avg_duration_ns, frame_time_ms); } /// Reset internal state which is used to calculate frame duration fn re...
{ FpsLog { last_second: Instant::now(), avg_duration_ns: 0, ticks: 0 } }
identifier_body
mod.rs
use std::time::{Instant, Duration}; use super::Figure; /// This struct is responsible for logging the average frame duration to stdout /// once a second. pub struct FpsLog { last_second: Instant, avg_duration_ns: u64, ticks: u64, } impl FpsLog { pub fn new() -> FpsLog { FpsLog { la...
self.add_frame_duration(duration); } }
{ self.print(); self.reset(); }
conditional_block
test.rs
#![crate_name = "test"] #![feature(libc)] #![feature(start)] extern crate libc; extern crate wx; use libc::c_void; use wx::_unsafe::*; use wx::defs::*; use wx::base::*; use wx::core::*; mod macros; wxApp!(wx_main); extern "C" fn wx_main()
fn make_frame() -> Frame { let frame = Frame::new(&Window::null(), ID_ANY, "Hello, wxRust!", -1, -1, -1, -1, DEFAULT_FRAME_STYLE); let menubar = make_menubar(); frame.setMenuBar(&menubar); make_button(&frame); frame } fn make_menubar() -> MenuBar { let menubar = MenuBar::new(0); ...
{ let frame = make_frame(); frame.show(); frame.raise(); }
identifier_body
test.rs
#![crate_name = "test"] #![feature(libc)] #![feature(start)] extern crate libc; extern crate wx; use libc::c_void; use wx::_unsafe::*; use wx::defs::*; use wx::base::*; use wx::core::*; mod macros; wxApp!(wx_main); extern "C" fn wx_main() { let frame = make_frame(); frame.show(); frame.raise(); } f...
println!("hello!"); let parent = Window::from(data); let msgDlg = MessageDialog::new(&parent, "Pushed!!", "The Button", OK); msgDlg.showModal(); } fn make_button<T: WindowMethods>(parent: &T) -> Button { let button = Button::new(parent, ID_ANY, "Push me!", 10, 10, 50, 30, 0); let closure = Cl...
{ // Comes here when the target widget is destroyed. return; }
conditional_block
test.rs
#![crate_name = "test"] #![feature(libc)] #![feature(start)] extern crate libc; extern crate wx; use libc::c_void; use wx::_unsafe::*; use wx::defs::*; use wx::base::*; use wx::core::*; mod macros; wxApp!(wx_main); extern "C" fn wx_main() { let frame = make_frame(); frame.show(); frame.raise(); } f...
<T: WindowMethods>(parent: &T) -> Button { let button = Button::new(parent, ID_ANY, "Push me!", 10, 10, 50, 30, 0); let closure = Closure::new(MyButton_clicked as *mut c_void, parent.ptr()); unsafe { button.connect(ID_ANY, ID_ANY, expEVT_COMMAND_BUTTON_CLICKED(), closure.ptr()); } button }
make_button
identifier_name
test.rs
#![crate_name = "test"] #![feature(libc)] #![feature(start)] extern crate libc; extern crate wx; use libc::c_void; use wx::_unsafe::*; use wx::defs::*; use wx::base::*; use wx::core::*; mod macros; wxApp!(wx_main); extern "C" fn wx_main() { let frame = make_frame(); frame.show(); frame.raise(); } f...
} fn make_menubar() -> MenuBar { let menubar = MenuBar::new(0); let fileMenu = Menu::new("", 0); let fileNew = MenuItem::newEx(ID_ANY, "New", "Create a new file.", 0, &Menu::null()); fileMenu.appendItem(&fileNew); menubar.append(&fileMenu, "File"); menubar } extern "C" fn MyButton_clicke...
make_button(&frame); frame
random_line_split
state.rs
use nalgebra::{Point2, Scalar, Vector2}; use std::collections::HashSet; use std::hash::Hash; use event::{ElementState, React}; /// An atomic state of an input element. pub trait State: Copy + Eq { // TODO: Use a default type (`Self`) here once that feature stabilizes. /// Representation of a difference betwee...
} /// An input element, such as a button, key, or position. pub trait Element: Copy + Sized { /// Representation of the state of the element. type State: State; } /// A state with a composite representation. This is used for input elements /// which have a cardinality greater than one. For example, a mouse ma...
T: Eq + Scalar, { type Difference = Vector2<T>;
random_line_split
state.rs
use nalgebra::{Point2, Scalar, Vector2}; use std::collections::HashSet; use std::hash::Hash; use event::{ElementState, React}; /// An atomic state of an input element. pub trait State: Copy + Eq { // TODO: Use a default type (`Self`) here once that feature stabilizes. /// Representation of a difference betwee...
} impl State for bool { type Difference = Self; } impl State for ElementState { type Difference = Self; } impl<T> State for Point2<T> where T: Eq + Scalar, { type Difference = Vector2<T>; } /// An input element, such as a button, key, or position. pub trait Element: Copy + Sized { /// Represent...
{ if live == snapshot { None } else { Some(live) } }
identifier_body
state.rs
use nalgebra::{Point2, Scalar, Vector2}; use std::collections::HashSet; use std::hash::Hash; use event::{ElementState, React}; /// An atomic state of an input element. pub trait State: Copy + Eq { // TODO: Use a default type (`Self`) here once that feature stabilizes. /// Representation of a difference betwee...
else { ElementState::Released } } } /// Provides a transition state for an input element. pub trait InputTransition<E> where E: Element, { /// Gets the transition state of an input element. fn transition(&self, element: E) -> Option<E::State>; } impl<E, T> InputTransition<...
{ ElementState::Pressed }
conditional_block
state.rs
use nalgebra::{Point2, Scalar, Vector2}; use std::collections::HashSet; use std::hash::Hash; use event::{ElementState, React}; /// An atomic state of an input element. pub trait State: Copy + Eq { // TODO: Use a default type (`Self`) here once that feature stabilizes. /// Representation of a difference betwee...
(&self, element: E) -> E::State { if self.composite().contains(&element) { ElementState::Pressed } else { ElementState::Released } } } /// Provides a transition state for an input element. pub trait InputTransition<E> where E: Element, { /// Gets the ...
state
identifier_name
dispnew.rs
//! Updating of data structures for redisplay. use std::{cmp, ptr}; use remacs_lib::current_timespec; use remacs_macros::lisp_fn; use crate::{ eval::unbind_to, frame::selected_frame, frame::{LispFrameLiveOrSelected, LispFrameRef}, lisp::{ExternalPtr, LispObject}, lists::{LispConsCircularChecks, L...
#[lisp_fn(c_name = "redraw_frame", name = "redraw-frame", min = "0")] pub fn redraw_frame_lisp(frame: LispFrameLiveOrSelected) { redraw_frame(frame.into()); } /// Clear and redisplay all visible frames. #[lisp_fn] pub fn redraw_display() { for_each_frame!(frame => { if frame.visible()!= 0 { ...
} /// Clear frame FRAME and output again what is supposed to appear on it. /// If FRAME is omitted or nil, the selected frame is used.
random_line_split
dispnew.rs
//! Updating of data structures for redisplay. use std::{cmp, ptr}; use remacs_lib::current_timespec; use remacs_macros::lisp_fn; use crate::{ eval::unbind_to, frame::selected_frame, frame::{LispFrameLiveOrSelected, LispFrameRef}, lisp::{ExternalPtr, LispObject}, lists::{LispConsCircularChecks, L...
} ret } } include!(concat!(env!("OUT_DIR"), "/dispnew_exports.rs"));
{ let force: bool = force.is_not_nil(); unsafe { swallow_events(true); let ret = (detect_input_pending_run_timers(true) && !force && !globals.redisplay_dont_pause) || globals.Vexecuting_kbd_macro.is_not_nil(); if ret { let count = c_specpdl_inde...
identifier_body
dispnew.rs
//! Updating of data structures for redisplay. use std::{cmp, ptr}; use remacs_lib::current_timespec; use remacs_macros::lisp_fn; use crate::{ eval::unbind_to, frame::selected_frame, frame::{LispFrameLiveOrSelected, LispFrameRef}, lisp::{ExternalPtr, LispObject}, lists::{LispConsCircularChecks, L...
(w: LispWindowRef, on_p: bool) { let mut w = Some(w); while let Some(mut win) = w { if let Some(contents) = win.contents.as_window() { set_window_update_flags(contents, on_p); } else { win.set_must_be_updated_p(on_p); } let next = win.next; w = if...
set_window_update_flags
identifier_name