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
fill.rs
use lyon::tessellation::FillOptions;
/// /// This trait allows the `Drawing` context to automatically provide an implementation of the /// following builder methods for all primitives that provide some fill tessellation options. pub trait SetFill: Sized { /// Provide a mutable reference to the `FillOptions` field. fn fill_options_mut(&mut self) ->...
/// Nodes that support fill tessellation.
random_line_split
fill.rs
use lyon::tessellation::FillOptions; /// Nodes that support fill tessellation. /// /// This trait allows the `Drawing` context to automatically provide an implementation of the /// following builder methods for all primitives that provide some fill tessellation options. pub trait SetFill: Sized { /// Provide a mut...
(mut self, orientation: lyon::tessellation::Orientation) -> Self { self.fill_options_mut().sweep_orientation = orientation; self } /// A fast path to avoid some expensive operations if the path is known to not have any /// self-intersections. /// /// Do not set this to `false` if th...
fill_sweep_orientation
identifier_name
ctl_flags.rs
// ctl_flags.rs use super::consts::*; // Represents control flags of a sysctl bitflags! { pub struct CtlFlags : libc::c_uint { /// Allow reads of variable const RD = CTLFLAG_RD; /// Allow writes to the variable const WR = CTLFLAG_WR; const RW = Self::RD.bits | Self::WR.bi...
/// Readable and writeable tunable const RWTUN = Self::RW.bits | Self::TUN.bits; /// Handler is MP safe const MPSAFE = CTLFLAG_MPSAFE; /// Prisons with vnet can fiddle const VNET = CTLFLAG_VNET; /// Oid is being removed const DYING = CTLFLAG_DYING; ...
random_line_split
ctl_flags.rs
// ctl_flags.rs use super::consts::*; // Represents control flags of a sysctl bitflags! { pub struct CtlFlags : libc::c_uint { /// Allow reads of variable const RD = CTLFLAG_RD; /// Allow writes to the variable const WR = CTLFLAG_WR; const RW = Self::RD.bits | Self::WR.bi...
() { // This sysctl should be read-only. #[cfg(any(target_os = "freebsd", target_os = "macos"))] let ctl: crate::Ctl = crate::Ctl::new("kern.ostype").unwrap(); #[cfg(any(target_os = "android", target_os = "linux"))] let ctl: crate::Ctl = crate::Ctl::new("kernel.ostype").unwrap();...
ctl_flags
identifier_name
ctl_flags.rs
// ctl_flags.rs use super::consts::*; // Represents control flags of a sysctl bitflags! { pub struct CtlFlags : libc::c_uint { /// Allow reads of variable const RD = CTLFLAG_RD; /// Allow writes to the variable const WR = CTLFLAG_WR; const RW = Self::RD.bits | Self::WR.bi...
}
{ // This sysctl should be read-only. #[cfg(any(target_os = "freebsd", target_os = "macos"))] let ctl: crate::Ctl = crate::Ctl::new("kern.ostype").unwrap(); #[cfg(any(target_os = "android", target_os = "linux"))] let ctl: crate::Ctl = crate::Ctl::new("kernel.ostype").unwrap(); ...
identifier_body
mod.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
}; run_puzzle(window, save_data, view) } // ========================================================================= //
&save_data.game_mut().cross_the_line, )
random_line_split
mod.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
// ========================================================================= //
{ let view = { let visible_rect = window.visible_rect(); View::new( &mut window.resources(), visible_rect, &save_data.game_mut().cross_the_line, ) }; run_puzzle(window, save_data, view) }
identifier_body
mod.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
( window: &mut Window, save_data: &mut SaveData, ) -> Mode { let view = { let visible_rect = window.visible_rect(); View::new( &mut window.resources(), visible_rect, &save_data.game_mut().cross_the_line, ) }; run_puzzle(window, save_data, v...
run_cross_the_line
identifier_name
utils.rs
#[allow(dead_code)] pub struct XorShift { x : i32, max : i32, cur : usize, count : usize, } impl XorShift { #[allow(dead_code)] pub fn new(seed : i32, max : i32, count: usize) -> XorShift { XorShift{x: seed, max: max, count: count, cur: 0} } } impl Iterator for XorShift { typ...
self.x ^= self.x >> 12; // a self.x ^= self.x << 25; // b self.x ^= self.x >> 27; // c self.cur += 1; return Some(self.x % self.max); } }
return None; }
random_line_split
utils.rs
#[allow(dead_code)] pub struct XorShift { x : i32, max : i32, cur : usize, count : usize, } impl XorShift { #[allow(dead_code)] pub fn new(seed : i32, max : i32, count: usize) -> XorShift { XorShift{x: seed, max: max, count: count, cur: 0} } } impl Iterator for XorShift { typ...
self.x ^= self.x >> 12; // a self.x ^= self.x << 25; // b self.x ^= self.x >> 27; // c self.cur += 1; return Some(self.x % self.max); } }
{ return None; }
conditional_block
utils.rs
#[allow(dead_code)] pub struct
{ x : i32, max : i32, cur : usize, count : usize, } impl XorShift { #[allow(dead_code)] pub fn new(seed : i32, max : i32, count: usize) -> XorShift { XorShift{x: seed, max: max, count: count, cur: 0} } } impl Iterator for XorShift { type Item = i32; fn next(&mut self) ->...
XorShift
identifier_name
networking.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 script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use task::{Task, TaskCanceller}; use...
impl NetworkingTaskSource { /// This queues a task that will not be cancelled when its associated /// global scope gets destroyed. pub fn queue_unconditionally<T>(&self, msg: Box<T>) -> Result<(), ()> where T: Task + Send +'static, { self.0.send(CommonScriptMsg::Task(ScriptThreadEven...
random_line_split
networking.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 script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use task::{Task, TaskCanceller}; use...
(pub Box<ScriptChan + Send +'static>); impl Clone for NetworkingTaskSource { fn clone(&self) -> NetworkingTaskSource { NetworkingTaskSource(self.0.clone()) } } impl TaskSource for NetworkingTaskSource { fn queue_with_canceller<T>( &self, msg: Box<T>, canceller: &TaskCancell...
NetworkingTaskSource
identifier_name
transform.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 values::computed::{Length, LengthOrPercentage, Number}; use values::generics::transform::TimingFunction as GenericTimingFunction; use values::generics::transform::TransformOrigin as GenericTransformOrigin; /// The computed value of a CSS `<transform-origin>` pub type TransformOrigin = GenericTransformOrigin<Length...
//! Computed types for CSS values that are related to transformations. use properties::animated_properties::Animatable;
random_line_split
transform.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/. */ //! Computed types for CSS values that are related to transformations. use properties::animated_properties::Anima...
} impl Animatable for TransformOrigin { #[inline] fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> { Ok(Self::new( self.horizontal.add_weighted(&other.horizontal, self_portion, other_portion)?, self.vertical.add_weighted(&other.ver...
{ Self::new( LengthOrPercentage::Percentage(0.5), LengthOrPercentage::Percentage(0.5), Length::from_px(0) ) }
identifier_body
transform.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/. */ //! Computed types for CSS values that are related to transformations. use properties::animated_properties::Anima...
(&self, other: &Self) -> Result<f64, ()> { self.compute_squared_distance(other).map(f64::sqrt) } #[inline] fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> { Ok( self.horizontal.compute_squared_distance(&other.horizontal)? + self.vertical.compute_s...
compute_distance
identifier_name
payload.rs
// Copyright 2020 lowRISC contributors. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
} impl ToWire for Header { fn to_wire<W: Write>(&self, mut w: W) -> Result<(), ToWireError> { w.write_be(self.content.to_wire_value())?; w.write_be(self.content_len)?; w.write_be(self.checksum)?; Ok(()) } }
{ let content_u8 = r.read_be::<u8>()?; let content = ContentType::from_wire_value(content_u8).ok_or(FromWireError::OutOfRange)?; let content_len = r.read_be::<u16>()?; let checksum = r.read_be::<u8>()?; Ok(Self { content, content_len, checksum,...
identifier_body
payload.rs
// Copyright 2020 lowRISC contributors. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
self.crc <<= 1; } } self } } /// Compute the checksum of the given header and payload buffer. pub fn compute_checksum(header: &Header, payload: &[u8]) -> u8 { Crc8::init() .add(&[header.content.to_wire_value()]) .add(&header.content_len.to_be_bytes())...
{ self.crc ^= 0x1070 << 3; }
conditional_block
payload.rs
// Copyright 2020 lowRISC contributors. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
Ok(()) } }
w.write_be(self.content.to_wire_value())?; w.write_be(self.content_len)?; w.write_be(self.checksum)?;
random_line_split
payload.rs
// Copyright 2020 lowRISC contributors. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
(&self) -> u8 { (self.crc >> 8 & 0xff) as u8 } /// Adds the specified data to the CRC8 checksum. /// Taken from /// https://chromium.googlesource.com/chromiumos/platform/vboot_reference/+/stabilize2/firmware/lib/crc8.c /// Uses x^8+x^2+x+1 polynomial. pub fn add(&mut self, data: &[u8]) ...
get
identifier_name
remux.rs
#![allow(unused)] //! Losslessly convert file formats without decoding. I.e. MP4 into something //! else, without altering the contained video, audio, etc. streams. //! //! Tested with this file: //! * [sintel_trailer-1080p.mp4](https://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4) //! * sha1: `66798612...
}; use libc::{c_float, c_void, size_t}; use std::convert::AsRef; use std::ffi::{CStr, CString}; use std::os::raw::{c_char, c_int}; use std::path::{Path, PathBuf}; fn c_str(s: &str) -> CString { CString::new(s).expect("str to c str") } unsafe fn remux(input_path: &str, output_path: &str) { // I/O assert!(P...
random_line_split
remux.rs
#![allow(unused)] //! Losslessly convert file formats without decoding. I.e. MP4 into something //! else, without altering the contained video, audio, etc. streams. //! //! Tested with this file: //! * [sintel_trailer-1080p.mp4](https://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4) //! * sha1: `66798612...
() { // HELPER FUNCTION pub fn path_exists(path: &str) -> bool { std::fs::metadata(path).is_ok() } // CLI Example: // ``` // cargo run --example remux -- \ // assets/samples/sintel_trailer.1080p.mp4 assets/output/test.mp4 // ``` fn run() -> Result<(), String> { le...
main
identifier_name
remux.rs
#![allow(unused)] //! Losslessly convert file formats without decoding. I.e. MP4 into something //! else, without altering the contained video, audio, etc. streams. //! //! Tested with this file: //! * [sintel_trailer-1080p.mp4](https://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4) //! * sha1: `66798612...
// WRITE OUTPUT let mut opts: *mut ffmpeg_dev::sys::AVDictionary = std::ptr::null_mut(); ffmpeg_dev::sys::av_dict_set( &mut opts, c_str("movflags").as_ptr(), c_str("frag_keyframe+empty_moov+default_base_moof").as_ptr(), 0, ); assert!(sys::avformat_write_header(ofmt_...
{ let status = sys::avio_open( &mut (*ofmt_ctx).pb, output_path_cstr.as_ptr(), AVIO_FLAG_WRITE as i32, ); assert!(status >= 0); }
conditional_block
remux.rs
#![allow(unused)] //! Losslessly convert file formats without decoding. I.e. MP4 into something //! else, without altering the contained video, audio, etc. streams. //! //! Tested with this file: //! * [sintel_trailer-1080p.mp4](https://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4) //! * sha1: `66798612...
if!path_exists(input_path) { return Err(String::from("missing input file")); } unsafe { remux(input_path, output_path); }; Ok(()) } match run() { Ok(()) => (), Err(msg) => { eprintln!("[failed] {:?}", msg); } ...
{ // HELPER FUNCTION pub fn path_exists(path: &str) -> bool { std::fs::metadata(path).is_ok() } // CLI Example: // ``` // cargo run --example remux -- \ // assets/samples/sintel_trailer.1080p.mp4 assets/output/test.mp4 // ``` fn run() -> Result<(), String> { let a...
identifier_body
htmldlistelement.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::HTMLDListElementBinding; use dom::bindings::js::Root; use dom::bindings::str...
(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<HTMLDListElement> { Node::reflect_node(box HTMLDListElement::new_inherited(local_name, prefix, document), document, HTMLDListElementBinding::Wrap) ...
new
identifier_name
htmldlistelement.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::HTMLDListElementBinding; use dom::bindings::js::Root; use dom::bindings::str...
} }
random_line_split
htmldlistelement.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::HTMLDListElementBinding; use dom::bindings::js::Root; use dom::bindings::str...
}
{ Node::reflect_node(box HTMLDListElement::new_inherited(local_name, prefix, document), document, HTMLDListElementBinding::Wrap) }
identifier_body
hash.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty. ...
} /// A Bitcoin hash, 32-bytes, computed from x as SHA256(SHA256(x)) pub struct Sha256dHash([u8; 32]); impl_array_newtype!(Sha256dHash, u8, 32); /// A RIPEMD-160 hash pub struct Ripemd160Hash([u8; 20]); impl_array_newtype!(Ripemd160Hash, u8, 20); /// A Bitcoin hash160, 20-bytes, computed from x as RIPEMD160(SHA256(...
{ match *self { HexError::BadLength(_) => "sha256d hex string non-64 length", HexError::BadCharacter(_) => "sha256d bad hex character" } }
identifier_body
hash.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty. ...
for x in (&mut ret).iter_mut() { *x = x.to_le(); } Uint256(ret) } /// Converts a hash to a big-endian Uint256 #[inline] pub fn into_be(self) -> Uint256 { let Sha256dHash(mut data) = self; data.reverse(); let mut ret: [u64; 4] = unsafe { mem::transmute(data) }; ...
pub fn into_le(self) -> Uint256 { let Sha256dHash(data) = self; let mut ret: [u64; 4] = unsafe { mem::transmute(data) };
random_line_split
hash.rs
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty. ...
([u8; 32]); impl_array_newtype!(Sha256dHash, u8, 32); /// A RIPEMD-160 hash pub struct Ripemd160Hash([u8; 20]); impl_array_newtype!(Ripemd160Hash, u8, 20); /// A Bitcoin hash160, 20-bytes, computed from x as RIPEMD160(SHA256(x)) pub struct Hash160([u8; 20]); impl_array_newtype!(Hash160, u8, 20); /// A 32-bit hash ob...
Sha256dHash
identifier_name
socket.rs
use chan::{self, Sender, Receiver}; use json; use serde::ser::Serialize; use std::io::{BufReader, Read, Write}; use std::net::Shutdown; use std::{fs, thread}; use unix_socket::{UnixListener, UnixStream}; use datatype::{Command, DownloadFailed, Error, Event}; use gateway::Gateway; use interpreter::CommandExec; /// Th...
Event::DownloadFailed(id, reason) => { EventWrapper::new("DownloadFailed", DownloadFailed { update_id: id, reason: reason }).to_json() } _ => return }; let _ = UnixStream::connect(ev_sock) .map_err(|err| debug!("skipping event socket broadcast: {}", err)) .m...
{ EventWrapper::new("DownloadComplete", dl).to_json() }
conditional_block
socket.rs
use chan::{self, Sender, Receiver}; use json; use serde::ser::Serialize; use std::io::{BufReader, Read, Write}; use std::net::Shutdown; use std::{fs, thread}; use unix_socket::{UnixListener, UnixStream}; use datatype::{Command, DownloadFailed, Error, Event}; use gateway::Gateway; use interpreter::CommandExec; /// Th...
(ev_sock: &str, event: Event) { let reply = match event { Event::DownloadComplete(dl) => { EventWrapper::new("DownloadComplete", dl).to_json() } Event::DownloadFailed(id, reason) => { EventWrapper::new("DownloadFailed", DownloadFailed { update_id: id, reason: reason ...
handle_event
identifier_name
socket.rs
use chan::{self, Sender, Receiver}; use json; use serde::ser::Serialize; use std::io::{BufReader, Read, Write}; use std::net::Shutdown; use std::{fs, thread}; use unix_socket::{UnixListener, UnixStream}; use datatype::{Command, DownloadFailed, Error, Event}; use gateway::Gateway; use interpreter::CommandExec; /// Th...
} fn handle_stream(mut stream: UnixStream, ctx: &Sender<CommandExec>) { info!("New socket connection."); let resp = parse_command(&mut stream, ctx) .map(|ev| json::to_vec(&ev).expect("couldn't encode Event")) .unwrap_or_else(|err| format!("{}", err).into_bytes()); stream.write_all(&resp).u...
{ info!("Listening for commands at socket {}", self.cmd_sock); info!("Sending events to socket {}", self.ev_sock); let _ = fs::remove_file(&self.cmd_sock); let cmd_sock = UnixListener::bind(&self.cmd_sock).expect("command socket"); let ev_sock = self.ev_sock.clone(); thr...
identifier_body
socket.rs
use chan::{self, Sender, Receiver}; use json; use serde::ser::Serialize; use std::io::{BufReader, Read, Write}; use std::net::Shutdown; use std::{fs, thread}; use unix_socket::{UnixListener, UnixStream}; use datatype::{Command, DownloadFailed, Error, Event}; use gateway::Gateway; use interpreter::CommandExec; /// Th...
#[test] fn socket_commands_and_events() { let (ctx, crx) = chan::sync::<CommandExec>(0); let (etx, erx) = chan::sync::<Event>(0); let mut socket = Socket { cmd_sock: CMD_SOCK.into(), ev_sock: EV_SOCK.into() }; thread::spawn(move || socket.start(ctx, erx)); let _ = fs::re...
random_line_split
dfa_builder.rs
// // Copyright 2016 Andrew Hunter // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law...
//! //! The DFA builder trait is implemented by classes that initialise DFAs. Deterministic Finite Automata can act as pattern //! matchers: for any given state, they only have a single possible transition for each input symbol. They can be efficiently //! implemented using a table-based approach. //! //! The main type...
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //
random_line_split
capture_actor.rs
/* * Exopticon - A free video surveillance system. * Copyright (C) 2020 David Matthew Mattli <dmm@mattli.us> * * This file is part of Exopticon. * * Exopticon 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 Founda...
fn finished(&mut self, _ctx: &mut Self::Context) { info!("Stream handler finished!"); } } /// Message for capture actor to start worker #[derive(Message)] #[rtype(result = "()")] struct StartWorker; impl Handler<StartWorker> for CaptureActor { type Result = (); fn handle(&mut self, _msg: St...
{ let item = match item { Ok(b) => b, Err(e) => { debug!("stream handle error! {}", e); self.stdin = None; ctx.terminate(); return; } }; let frame: Result<CaptureMessage, bincode::Error> = bincode...
identifier_body
capture_actor.rs
/* * Exopticon - A free video surveillance system. * Copyright (C) 2020 David Matthew Mattli <dmm@mattli.us> * * This file is part of Exopticon. * * Exopticon 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 Founda...
} /// Processes a `CaptureMessage` from the capture worker, /// performing the appropriate action. #[allow(clippy::panic)] fn message_to_action(&mut self, msg: CaptureMessage, ctx: &mut Context<Self>) { // Check if log match msg { CaptureMessage::Log { message } => { ...
error!("Error closing file!"); }
random_line_split
capture_actor.rs
/* * Exopticon - A free video surveillance system. * Copyright (C) 2020 David Matthew Mattli <dmm@mattli.us> * * This file is part of Exopticon. * * Exopticon 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 Founda...
(&self, ctx: &mut Context<Self>, filename: &str, end_time: DateTime<Utc>) { if let (Some(video_unit_id), Some(video_file_id), Ok(metadata)) = ( self.video_unit_id, self.video_file_id, fs::metadata(filename), ) { let fut = db_registry::get_db().send(UpdateV...
close_file
identifier_name
basic_types.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
//! Ethcore basic typenames. use util::hash::H2048; /// Type for a 2048-bit log-bloom, as used by our blocks. pub type LogBloom = H2048; /// Constant 2048-bit datum for 0. Often used as a default. pub static ZERO_LOGBLOOM: LogBloom = H2048([0x00; 256]); #[cfg_attr(feature="dev", allow(enum_variant_names))] /// Sema...
random_line_split
basic_types.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
{ /// The seal/signature is included. With, /// The seal/signature is not included. Without, }
Seal
identifier_name
img.rs
use std::default::{Default}; use std::cmp::{min, max}; use std::convert::{Into}; use image::{Primitive, GenericImage, Pixel, ImageBuffer, Rgba}; use geom::{V2, Rect}; use rgb; /// Set alpha channel to transparent if pixels have a specific color. pub fn color_key<P: Pixel<Subpixel=u8>, I: GenericImage<Pixel=P>, C: Into...
<T, P, I, J>(image: &I, target: &mut J, offset: V2<i32>) where T: Primitive+Default, P: Pixel<Subpixel=T>, I: GenericImage<Pixel=P>, J: GenericImage<Pixel=P> { let (w, h) = image.dimensions(); // TODO: Check for going over bounds. for y in 0..(h) { for x in 0..(w) {...
blit
identifier_name
img.rs
use std::default::{Default}; use std::cmp::{min, max}; use std::convert::{Into}; use image::{Primitive, GenericImage, Pixel, ImageBuffer, Rgba}; use geom::{V2, Rect}; use rgb; /// Set alpha channel to transparent if pixels have a specific color.
let (w, h) = image.dimensions(); let srgba = color.into(); ImageBuffer::from_fn(w, h, |x, y| { let (pr, pg, pb, mut pa) = image.get_pixel(x, y).to_rgba().channels4(); if pr == srgba.r && pg == srgba.g && pb == srgba.b { pa = Default::default(); } Pixel::from_chann...
pub fn color_key<P: Pixel<Subpixel=u8>, I: GenericImage<Pixel=P>, C: Into<rgb::SRgba>>( image: &I, color: C) -> ImageBuffer<Rgba<u8>, Vec<u8>> {
random_line_split
img.rs
use std::default::{Default}; use std::cmp::{min, max}; use std::convert::{Into}; use image::{Primitive, GenericImage, Pixel, ImageBuffer, Rgba}; use geom::{V2, Rect}; use rgb; /// Set alpha channel to transparent if pixels have a specific color. pub fn color_key<P: Pixel<Subpixel=u8>, I: GenericImage<Pixel=P>, C: Into...
// Empty image. else { Rect(p1, p2 - p1) } } pub fn blit<T, P, I, J>(image: &I, target: &mut J, offset: V2<i32>) where T: Primitive+Default, P: Pixel<Subpixel=T>, I: GenericImage<Pixel=P>, J: GenericImage<Pixel=P> { let (w, h) = image.dimensions(); // TODO: Check for goin...
{ Rect(V2(0, 0), V2(0, 0)) }
conditional_block
img.rs
use std::default::{Default}; use std::cmp::{min, max}; use std::convert::{Into}; use image::{Primitive, GenericImage, Pixel, ImageBuffer, Rgba}; use geom::{V2, Rect}; use rgb; /// Set alpha channel to transparent if pixels have a specific color. pub fn color_key<P: Pixel<Subpixel=u8>, I: GenericImage<Pixel=P>, C: Into...
{ let (w, h) = image.dimensions(); // TODO: Check for going over bounds. for y in 0..(h) { for x in 0..(w) { target.put_pixel(x + offset.0 as u32, y + offset.1 as u32, image.get_pixel(x, y)); } } }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ extern crate hashglobe; extern crate smallvec; #[cfg(feature = "known_system_malloc")] use hashglobe::alloc; use...
if new_ptr.is_null() { return Err(FailedAllocationError::new( "out of memory when allocating SmallVec", )); } let new_vec = unsafe { Vec::from_raw_parts(new_ptr as *mut T::Item, old_len, new_cap) }; let new_svec = SmallVec::from_vec(new_vec); mem::forget(mem::replace(s...
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ extern crate hashglobe; extern crate smallvec; #[cfg(feature = "known_system_malloc")] use hashglobe::alloc; use...
} // Double the capacity of |vec|, or fail to do so due to lack of memory. // Returns Ok(()) on success, Err(..) on failure. #[cfg(feature = "known_system_malloc")] #[inline(never)] #[cold] fn try_double_vec<T>(vec: &mut Vec<T>) -> Result<(), FailedAllocationError> { use std::mem; let old_ptr = vec.as_mut_pt...
{ #[cfg(feature = "known_system_malloc")] { if self.capacity() == self.len() { try_double_vec(self)?; debug_assert!(self.capacity() > self.len()); } } self.push(val); Ok(()) }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ extern crate hashglobe; extern crate smallvec; #[cfg(feature = "known_system_malloc")] use hashglobe::alloc; use...
(&mut self, val: T::Item) -> Result<(), FailedAllocationError> { #[cfg(feature = "known_system_malloc")] { if self.capacity() == self.len() { try_double_small_vec(self)?; debug_assert!(self.capacity() > self.len()); } } self.push(va...
try_push
identifier_name
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ extern crate hashglobe; extern crate smallvec; #[cfg(feature = "known_system_malloc")] use hashglobe::alloc; use...
else { old_cap .checked_mul(2) .ok_or(FailedAllocationError::new("capacity overflow for SmallVec"))? }; // This surely shouldn't fail, if |old_cap| was previously accepted as a // valid value. But err on the side of caution. let old_size_bytes = old_cap .checked_m...
{ 4 }
conditional_block
coercion.rs
for avoiding the linearity //! of mut things (when the expected is &mut T and you have &mut T). See //! the various `src/test/run-pass/coerce-reborrow-*.rs` tests for //! examples of where this is useful. //! //! ## Subtle note //! //! When deciding what type coercions to consider, we do not attempt to //! resolve an...
<'a, 'tcx: 'a> { fcx: &'a FnCtxt<'a, 'tcx>, origin: infer::TypeOrigin, unsizing_obligations: RefCell<Vec<traits::PredicateObligation<'tcx>>>, } type CoerceResult<'tcx> = RelateResult<'tcx, Option<ty::AutoAdjustment<'tcx>>>; impl<'f, 'tcx> Coerce<'f, 'tcx> { fn tcx(&self) -> &ty::ctxt<'tcx> { s...
Coerce
identifier_name
coercion.rs
also for avoiding the linearity //! of mut things (when the expected is &mut T and you have &mut T). See //! the various `src/test/run-pass/coerce-reborrow-*.rs` tests for //! examples of where this is useful. //! //! ## Subtle note //! //! When deciding what type coercions to consider, we do not attempt to //! resol...
} ty::TyBareFn(None, a_f) => { // We permit coercion of fn pointers to drop the // unsafe qualifier. self.coerce_from_fn_pointer(a, a_f, b) } _ => { // Otherwise, just use subt...
// type; function pointers are not (that would // require double indirection). self.coerce_from_fn_item(a, a_f, b)
random_line_split
coercion.rs
for avoiding the linearity //! of mut things (when the expected is &mut T and you have &mut T). See //! the various `src/test/run-pass/coerce-reborrow-*.rs` tests for //! examples of where this is useful. //! //! ## Subtle note //! //! When deciding what type coercions to consider, we do not attempt to //! resolve an...
fn coerce_unsafe_ptr(&self, a: Ty<'tcx>, b: Ty<'tcx>, mutbl_b: ast::Mutability) -> CoerceResult<'tcx> { debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b); let (is_ref,...
{ /*! * Attempts to coerce from the type of a Rust function item * into a closure or a `proc`. */ self.unpack_actual_value(b, |b| { debug!("coerce_from_fn_item(a={:?}, b={:?})", a, b); match b.sty { ty::TyBareFn(None...
identifier_body
viewport.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 cssparser::{Parser, ToCss}; use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; use std::asc...
<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { Zoom::Number(number) => write!(dest, "{}", number), Zoom::Percentage(percentage) => write!(dest, "{}%", percentage * 100.), Zoom::Auto => write!(dest, "auto") } } } impl Zoom ...
to_css
identifier_name
viewport.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 cssparser::{Parser, ToCss}; use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; use std::asc...
} } #[inline] pub fn to_f32(&self) -> Option<f32> { match *self { Zoom::Number(number) => Some(number as f32), Zoom::Percentage(percentage) => Some(percentage as f32), Zoom::Auto => None } } }
random_line_split
bitpacker.rs
use std::io::Write; use std::io; use common::serialize::BinarySerializable; use std::mem; /// Computes the number of bits that will be used for bitpacking. /// /// In general the target is the minimum number of bits /// required to express the amplitude given in argument. /// /// e.g. If the amplitude is 10, we can s...
<TWrite: Write>(&mut self, output: &mut TWrite) -> io::Result<()> { if self.mini_buffer_written > 0 { let num_bytes = (self.mini_buffer_written + 7) / 8; let arr: [u8; 8] = unsafe { mem::transmute::<u64, [u8; 8]>(self.mini_buffer) }; output.write_all(&arr[..num_bytes])?; ...
flush
identifier_name
bitpacker.rs
use std::io::Write; use std::io; use common::serialize::BinarySerializable; use std::mem; /// Computes the number of bits that will be used for bitpacking. /// /// In general the target is the minimum number of bits /// required to express the amplitude given in argument. /// /// e.g. If the amplitude is 10, we can s...
) .collect(); for &val in &vals { bitpacker.write(val, &mut data).unwrap(); } let num_bytes = bitpacker.close(&mut data).unwrap(); assert_eq!(num_bytes, (num_bits * len + 7) / 8 + 7); assert_eq!(data.len(), num_bytes); let bitunpacker = BitUnpacker:...
{ i % max_val }
conditional_block
bitpacker.rs
use std::io::Write; use std::io; use common::serialize::BinarySerializable; use std::mem; /// Computes the number of bits that will be used for bitpacking. /// /// In general the target is the minimum number of bits /// required to express the amplitude given in argument. /// /// e.g. If the amplitude is 10, we can s...
data_ptr: data.as_ptr(), data_len: data.len(), } } pub fn get(&self, idx: usize) -> u64 { if self.num_bits == 0 { return 0; } let addr = (idx * self.num_bits) / 8; let bit_shift = idx * self.num_bits - addr * 8; let val_unshift...
random_line_split
regions-close-over-type-parameter-2.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn repeater3<'a,A:'a>(v: A) -> Box<Foo+'a> { box v as Box<Foo+'a> } fn main() { // Error results because the type of is inferred to be // ~Repeat<&'blk isize> where blk is the lifetime of the block below. let _ = { let tmp0 = 3; let tmp1 = &tmp0; //~ ERROR `tmp0` does not live long...
{ }
identifier_body
regions-close-over-type-parameter-2.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 _ = { let tmp0 = 3; let tmp1 = &tmp0; //~ ERROR `tmp0` does not live long enough repeater3(tmp1) };
random_line_split
regions-close-over-type-parameter-2.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 ...
() { // Error results because the type of is inferred to be // ~Repeat<&'blk isize> where blk is the lifetime of the block below. let _ = { let tmp0 = 3; let tmp1 = &tmp0; //~ ERROR `tmp0` does not live long enough repeater3(tmp1) }; }
main
identifier_name
lin_reg.rs
use rm::linalg::Matrix; use rm::linalg::Vector; use rm::learning::SupModel; use rm::learning::lin_reg::LinRegressor; use libnum::abs; #[test] fn test_optimized_regression() { let mut lin_mod = LinRegressor::default(); let inputs = Matrix::new(3, 1, vec![2.0, 3.0, 4.0]); let targets = Vector::new(vec![5.0, ...
() { let inputs = Matrix::new(0, 1, vec![]); let targets = Vector::new(vec![]); let mut lin_mod = LinRegressor::default(); let res = lin_mod.train(&inputs, &targets); assert!(res.is_err()); }
test_train_no_data
identifier_name
lin_reg.rs
use rm::linalg::Matrix; use rm::linalg::Vector; use rm::learning::SupModel; use rm::learning::lin_reg::LinRegressor; use libnum::abs; #[test] fn test_optimized_regression() { let mut lin_mod = LinRegressor::default(); let inputs = Matrix::new(3, 1, vec![2.0, 3.0, 4.0]); let targets = Vector::new(vec![5.0, ...
#[test] #[ignore = "FIXME #183 fails nondeterministically"] fn test_train_no_data() { let inputs = Matrix::new(0, 1, vec![]); let targets = Vector::new(vec![]); let mut lin_mod = LinRegressor::default(); let res = lin_mod.train(&inputs, &targets); assert!(res.is_err()); }
{ use rm::datasets::trees; let trees = trees::load(); let mut lin_mod = LinRegressor::default(); lin_mod.train(&trees.data(), &trees.target()).unwrap(); let params = lin_mod.parameters().unwrap(); assert_eq!(params, &Vector::new(vec![-57.98765891838409, 4.708160503017506, 0.3392512342447438]));...
identifier_body
lin_reg.rs
use rm::linalg::Matrix; use rm::linalg::Vector; use rm::learning::SupModel; use rm::learning::lin_reg::LinRegressor; use libnum::abs; #[test] fn test_optimized_regression() { let mut lin_mod = LinRegressor::default(); let inputs = Matrix::new(3, 1, vec![2.0, 3.0, 4.0]); let targets = Vector::new(vec![5.0, ...
let lin_mod = LinRegressor::default(); let inputs = Matrix::new(3, 2, vec![1.0, 2.0, 1.0, 3.0, 1.0, 4.0]); let _ = lin_mod.predict(&inputs).unwrap(); } #[cfg(feature = "datasets")] #[test] fn test_regression_datasets_trees() { use rm::datasets::trees; let trees = trees::load(); let mut lin_mo...
fn test_no_train_predict() {
random_line_split
decompressor.rs
use ll; use parse_code; use std::io; struct DecoderContext { c: *mut ll::ZSTD_DCtx, } impl Default for DecoderContext { fn default() -> Self { DecoderContext { c: unsafe { ll::ZSTD_createDCtx() }, } } } impl Drop for DecoderContext { fn drop(&mut self) { let code ...
self.dict.len(), ) }; parse_code(code) } /// Decompress a block of data, and return the decompressed result in a `Vec<u8>`. /// /// The decompressed data should be less than `capacity` bytes, /// or an error will be returned. pub fn decompress( ...
random_line_split
decompressor.rs
use ll; use parse_code; use std::io; struct DecoderContext { c: *mut ll::ZSTD_DCtx, } impl Default for DecoderContext { fn
() -> Self { DecoderContext { c: unsafe { ll::ZSTD_createDCtx() }, } } } impl Drop for DecoderContext { fn drop(&mut self) { let code = unsafe { ll::ZSTD_freeDCtx(self.c) }; parse_code(code).unwrap(); } } /// Allows to decompress independently multiple blocks of...
default
identifier_name
decompressor.rs
use ll; use parse_code; use std::io; struct DecoderContext { c: *mut ll::ZSTD_DCtx, } impl Default for DecoderContext { fn default() -> Self
} impl Drop for DecoderContext { fn drop(&mut self) { let code = unsafe { ll::ZSTD_freeDCtx(self.c) }; parse_code(code).unwrap(); } } /// Allows to decompress independently multiple blocks of data. /// /// This reduces memory usage compared to calling `decompress` multiple times. #[derive(Def...
{ DecoderContext { c: unsafe { ll::ZSTD_createDCtx() }, } }
identifier_body
mod.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 servo::config::opts; use std::ptr; use std::thread; use std::time::Duration; pub fn deinit() { // An unf...
else { println!("All threads have shutdown (good)."); } } #[link_section = "__TEXT,__info_plist"] #[no_mangle] pub static INFO_PLIST: [u8; 619] = *include_bytes!("Info.plist"); #[link(name = "count_threads")] extern { fn macos_count_running_threads() -> i32; }
{ println!("{} threads are still running after shutdown (bad).", thread_count); if opts::get().clean_shutdown { println!("Waiting until all threads have shutdown"); loop { let thread_count = unsafe { macos_count_running_threads() ...
conditional_block
mod.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 servo::config::opts; use std::ptr; use std::thread; use std::time::Duration; pub fn deinit() { // An unf...
} } #[link_section = "__TEXT,__info_plist"] #[no_mangle] pub static INFO_PLIST: [u8; 619] = *include_bytes!("Info.plist"); #[link(name = "count_threads")] extern { fn macos_count_running_threads() -> i32; }
println!("{} threads are still running.", thread_count); } } } else { println!("All threads have shutdown (good).");
random_line_split
mod.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 servo::config::opts; use std::ptr; use std::thread; use std::time::Duration; pub fn
() { // An unfortunate hack to make sure the linker's dead code stripping doesn't strip our // `Info.plist`. unsafe { ptr::read_volatile(&INFO_PLIST[0]); } let thread_count = unsafe { macos_count_running_threads() }; if thread_count!= 1 { println!("{} threads are st...
deinit
identifier_name
mod.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 servo::config::opts; use std::ptr; use std::thread; use std::time::Duration; pub fn deinit()
break; } thread::sleep(Duration::from_millis(1000)); println!("{} threads are still running.", thread_count); } } } else { println!("All threads have shutdown (good)."); } } #[link_section = "__TEXT,__info_plist"] ...
{ // An unfortunate hack to make sure the linker's dead code stripping doesn't strip our // `Info.plist`. unsafe { ptr::read_volatile(&INFO_PLIST[0]); } let thread_count = unsafe { macos_count_running_threads() }; if thread_count != 1 { println!("{} threads are stil...
identifier_body
extra.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
use layout::wrapper::LayoutNode; use script::layout_interface::LayoutChan; /// Functionality useful for querying the layout-specific data on DOM nodes. pub trait LayoutAuxMethods { fn initialize_layout_data(self, chan: LayoutChan); fn initialize_style_for_subtree(self, chan: LayoutChan); } impl<'ln> LayoutAux...
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Code for managing the layout data in the DOM. use layout::util::{PrivateLayoutData, LayoutDataAccess, LayoutDataWrapper};
random_line_split
extra.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/. */ //! Code for managing the layout data in the DOM. use layout::util::{PrivateLayoutData, LayoutDataAccess, LayoutD...
}
{ for n in self.traverse_preorder() { n.initialize_layout_data(chan.clone()); } }
identifier_body
extra.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/. */ //! Code for managing the layout data in the DOM. use layout::util::{PrivateLayoutData, LayoutDataAccess, LayoutD...
(self, chan: LayoutChan) { let mut layout_data_ref = self.mutate_layout_data(); match *layout_data_ref.get() { None => { *layout_data_ref.get() = Some(LayoutDataWrapper { chan: Some(chan), data: ~PrivateLayoutData::new(), ...
initialize_layout_data
identifier_name
read_only_memory.rs
// Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #![cfg(any(target_arch = "x86", target_arch = "x86_64"))] use base::{MemoryMappingBuilder, SharedMemory}; use kvm::*; use kvm_sys::kvm_regs; use vm_me...
let kvm = Kvm::new().expect("new kvm failed"); let mut vm = Vm::new(&kvm, guest_mem).expect("new vm failed"); let vcpu = Vcpu::new(0, &kvm, &vm).expect("new vcpu failed"); let mut vcpu_sregs = vcpu.get_sregs().expect("get sregs failed"); vcpu_sregs.cs.base = 0; vcpu_sregs.cs.selector = 0; vc...
{ /* 0000 268A07 mov al,[es:bx] 0003 0401 add al,0x1 0005 268807 mov [es:bx],al 0008 F4 hlt */ let code = [0x26, 0x8a, 0x07, 0x04, 0x01, 0x26, 0x88, 0x07, 0xf4]; let mem_size = 0x2000; let load_addr = GuestAddress(0x1000); let guest_mem = GuestMemory::new(&[]).unwra...
identifier_body
read_only_memory.rs
// Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #![cfg(any(target_arch = "x86", target_arch = "x86_64"))] use base::{MemoryMappingBuilder, SharedMemory}; use kvm::*; use kvm_sys::kvm_regs; use vm_me...
GuestAddress(0), Box::new( MemoryMappingBuilder::new(mem_size as usize) .from_shared_memory(&mem) .build() .expect("failed to create memory mapping"), ), false, false, ) .expect("failed to register memory"); // ...
random_line_split
read_only_memory.rs
// Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #![cfg(any(target_arch = "x86", target_arch = "x86_64"))] use base::{MemoryMappingBuilder, SharedMemory}; use kvm::*; use kvm_sys::kvm_regs; use vm_me...
() { /* 0000 268A07 mov al,[es:bx] 0003 0401 add al,0x1 0005 268807 mov [es:bx],al 0008 F4 hlt */ let code = [0x26, 0x8a, 0x07, 0x04, 0x01, 0x26, 0x88, 0x07, 0xf4]; let mem_size = 0x2000; let load_addr = GuestAddress(0x1000); let guest_mem = GuestMemory::new(&[]).un...
test_run
identifier_name
compensate.rs
#include <constants.rh> #include <crctools.rh> #include <math.rh> #include <util.rh> ; vim: syntax=fasm _start: mov r3, #0x1000 ; Output buffer address mov [r3], #0x6c6c6548 ; 'lleH' mov [r3+#4], #0x57202c6f ; 'W,o' mov [r3+#8], #0x646c726f ; 'dlro'
jz $next call $_error next: push #0xDEADBEEF push #14 push #0x1000 call $_compensate_crc test r0, r0 jz $verify call $_error verify: push #14 push #0x1000 call $_crc_block cmp r0, #0xDEADBEEF jz $finish call ...
mov [r3+#12], #0x00000a21 ; '!\n' push #14 ; Length push r3 ; Pointer call $_crc_block cmp r0, #0x4b17617b ; Check value
random_line_split
abort.rs
// Copyright 2021 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
(iss: u64) -> Result<Vec<FieldInfo>, DecodeError> { let res0a = FieldInfo::get(iss, "RES0", Some("Reserved"), 13, 25).check_res0()?; let fnv = FieldInfo::get_bit(iss, "FnV", Some("FAR not Valid"), 10).describe_bit(describe_fnv); let ea = FieldInfo::get_bit(iss, "EA", Some("External abort type"), 9); let...
decode_iss_instruction_abort
identifier_name
abort.rs
// Copyright 2021 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
} 0b010110 => { "Synchronous External abort on translation table walk or hardware update of \ translation table, level 2." } 0b010111 => { "Synchronous External abort on translation table walk or hardware update of \ translation table, le...
translation table, level 0." } 0b010101 => { "Synchronous External abort on translation table walk or hardware update of \ translation table, level 1."
random_line_split
lib.rs
//! The `pact_consumer` crate provides tools for writing consumer [Pact //! tests][pact]. It implements the [V3 Pact specification][spec]. You can also //! use it as a simple HTTP mocking library for Rust. //! //! [pact]: https://docs.pact.io/ [spec]: //! https://github.com/pact-foundation/pact-specification //! //! ##...
//! // Return the interaction builder back to the pact framework //! i //! }) //! .await //! .build(); //! # }); //! ``` //! //! You can than use an HTTP client like `reqwest` to make requests against your //! server. //! //! ```rust //! # tokio_test::block_on(async { //! # use pact_models::pa...
random_line_split
game.rs
use std::cell::RefCell; use std::collections::HashSet; use std::rc::Rc; use slackbot::{CommandHandler, Sender}; use rand::{self, Rng}; pub struct GameCommandHandler {
GameCommandHandler { registered_users: user_store } } } impl CommandHandler for GameCommandHandler { fn handle(&mut self, sender: &mut Sender, args: &Vec<String>) { let team_size = if args.len() > 0 && args[0] == "1v1" { 1 } else { 2 }; let users = self.registered_us...
registered_users: Rc<RefCell<HashSet<String>>> } impl GameCommandHandler { pub fn new(user_store: Rc<RefCell<HashSet<String>>>) -> Self {
random_line_split
game.rs
use std::cell::RefCell; use std::collections::HashSet; use std::rc::Rc; use slackbot::{CommandHandler, Sender}; use rand::{self, Rng}; pub struct GameCommandHandler { registered_users: Rc<RefCell<HashSet<String>>> } impl GameCommandHandler { pub fn new(user_store: Rc<RefCell<HashSet<String>>>) -> Self { ...
; let users = self.registered_users.borrow(); if users.len() < team_size * 2 { sender.respond_in_channel(format!("Not enough players! Need {0} players to be registered to start a game.", team_size * 2)).unwrap(); } else { let mut users = &mut users.iter().collect::<Vec<_>...
{ 2 }
conditional_block
game.rs
use std::cell::RefCell; use std::collections::HashSet; use std::rc::Rc; use slackbot::{CommandHandler, Sender}; use rand::{self, Rng}; pub struct GameCommandHandler { registered_users: Rc<RefCell<HashSet<String>>> } impl GameCommandHandler { pub fn new(user_store: Rc<RefCell<HashSet<String>>>) -> Self { ...
(&mut self, sender: &mut Sender, args: &Vec<String>) { let team_size = if args.len() > 0 && args[0] == "1v1" { 1 } else { 2 }; let users = self.registered_users.borrow(); if users.len() < team_size * 2 { sender.respond_in_channel(format!("Not enough players! Need {0} players to be re...
handle
identifier_name
hash_join.rs
// http://rosettacode.org/wiki/Hash_join use std::collections::HashMap; type LeftTable<'a> = Vec<(i64, &'a str)>; type RightTable<'a> = Vec<(&'a str, &'a str)>; type ResultTable<'a> = Vec<(i64, &'a str, &'a str)>; fn hash_join<'a>(s: LeftTable<'a>, r: RightTable<'a>) -> ResultTable<'a> { let mut hash_map: HashMa...
() { let table1 = vec![(27, "Jonah"), (18, "Alan"), (28, "Glory"), (18, "Popeye"), (28, "Alan")]; let table2 = vec![("Jonah", "Whales"), ("Jonah", "Spiders"), ("Alan", "Ghosts"), ("Alan", "Zombies"), ...
main
identifier_name
hash_join.rs
// http://rosettacode.org/wiki/Hash_join use std::collections::HashMap; type LeftTable<'a> = Vec<(i64, &'a str)>; type RightTable<'a> = Vec<(&'a str, &'a str)>; type ResultTable<'a> = Vec<(i64, &'a str, &'a str)>; fn hash_join<'a>(s: LeftTable<'a>, r: RightTable<'a>) -> ResultTable<'a>
} return result; } #[cfg(not(test))] pub fn main() { let table1 = vec![(27, "Jonah"), (18, "Alan"), (28, "Glory"), (18, "Popeye"), (28, "Alan")]; let table2 = vec![("Jonah", "Whales"), ("Jonah", "Spiders"), ("Alan", "G...
{ let mut hash_map: HashMap<&str, Vec<&str>> = HashMap::new(); //hash phase for (name, nemesis) in r { if hash_map.contains_key(name) { hash_map.get_mut(name).unwrap().push(nemesis); } else { hash_map.insert(name, vec![nemesis]); } } let mut result =...
identifier_body
hash_join.rs
// http://rosettacode.org/wiki/Hash_join use std::collections::HashMap; type LeftTable<'a> = Vec<(i64, &'a str)>; type RightTable<'a> = Vec<(&'a str, &'a str)>; type ResultTable<'a> = Vec<(i64, &'a str, &'a str)>; fn hash_join<'a>(s: LeftTable<'a>, r: RightTable<'a>) -> ResultTable<'a> { let mut hash_map: HashMa...
let mut result = vec![]; //join phase for (age, name) in s { if let Some(v) = hash_map.get(name) { for nemesis in v { result.push((age, name, *nemesis)); } } } return result; } #[cfg(not(test))] pub fn main() { let table1 = vec![(27, "Jonah")...
} }
random_line_split
hash_join.rs
// http://rosettacode.org/wiki/Hash_join use std::collections::HashMap; type LeftTable<'a> = Vec<(i64, &'a str)>; type RightTable<'a> = Vec<(&'a str, &'a str)>; type ResultTable<'a> = Vec<(i64, &'a str, &'a str)>; fn hash_join<'a>(s: LeftTable<'a>, r: RightTable<'a>) -> ResultTable<'a> { let mut hash_map: HashMa...
} let mut result = vec![]; //join phase for (age, name) in s { if let Some(v) = hash_map.get(name) { for nemesis in v { result.push((age, name, *nemesis)); } } } return result; } #[cfg(not(test))] pub fn main() { let table1 = vec![(27, ...
{ hash_map.insert(name, vec![nemesis]); }
conditional_block
config.rs
use alloc::boxed::Box; use fs::{KScheme, Resource, SliceResource, SliceMutResource}; use network::common::{DNS_ADDR, IP_ADDR, IP_ROUTER_ADDR, IP_SUBNET, MAC_ADDR}; use system::error::{Error, ENOENT, Result}; use system::syscall::{MODE_DIR, MODE_FILE}; /// Network configuration scheme pub struct
; impl KScheme for NetConfigScheme { fn scheme(&self) -> &str { "netcfg" } fn open(&mut self, url: &str, _: usize) -> Result<Box<Resource>> { match url.splitn(2, ":").nth(1).unwrap_or("") { "dns" => Ok(Box::new(SliceMutResource::new("netcfg:dns", unsafe { &mut DNS_ADDR.bytes },...
NetConfigScheme
identifier_name
config.rs
use alloc::boxed::Box; use fs::{KScheme, Resource, SliceResource, SliceMutResource}; use network::common::{DNS_ADDR, IP_ADDR, IP_ROUTER_ADDR, IP_SUBNET, MAC_ADDR}; use system::error::{Error, ENOENT, Result}; use system::syscall::{MODE_DIR, MODE_FILE}; /// Network configuration scheme
"netcfg" } fn open(&mut self, url: &str, _: usize) -> Result<Box<Resource>> { match url.splitn(2, ":").nth(1).unwrap_or("") { "dns" => Ok(Box::new(SliceMutResource::new("netcfg:dns", unsafe { &mut DNS_ADDR.bytes }, MODE_FILE))), "ip" => Ok(Box::new(SliceMutResource::new(...
pub struct NetConfigScheme; impl KScheme for NetConfigScheme { fn scheme(&self) -> &str {
random_line_split
config.rs
use alloc::boxed::Box; use fs::{KScheme, Resource, SliceResource, SliceMutResource}; use network::common::{DNS_ADDR, IP_ADDR, IP_ROUTER_ADDR, IP_SUBNET, MAC_ADDR}; use system::error::{Error, ENOENT, Result}; use system::syscall::{MODE_DIR, MODE_FILE}; /// Network configuration scheme pub struct NetConfigScheme; impl ...
fn open(&mut self, url: &str, _: usize) -> Result<Box<Resource>> { match url.splitn(2, ":").nth(1).unwrap_or("") { "dns" => Ok(Box::new(SliceMutResource::new("netcfg:dns", unsafe { &mut DNS_ADDR.bytes }, MODE_FILE))), "ip" => Ok(Box::new(SliceMutResource::new("netcfg:ip", unsafe { ...
{ "netcfg" }
identifier_body
vga.rs
//! VGA helpers use core::fmt::Write; use log::*; use spin::Mutex; const ROWS: usize = 25; const COLS: usize = 80; pub struct VgaWriter { vmem: *mut u8, offset: usize, } impl VgaWriter { pub unsafe fn new(vmem: *mut u8) -> VgaWriter { let mut vga_writer = VgaWriter { vmem, offset: 0 }; v...
let b = if c.is_ascii() { c as u8 } else { '?' as u8 }; unsafe { *self.vmem.offset(2 * self.offset as isize) = b; } self.offset += 1; } Ok(()) } } pub struct VgaLog { writer: Mutex<VgaWriter>, } impl VgaLog { pub fn new(w...
{ self.offset = ((self.offset + COLS) / COLS) * COLS; continue; }
conditional_block
vga.rs
//! VGA helpers use core::fmt::Write; use log::*; use spin::Mutex; const ROWS: usize = 25; const COLS: usize = 80; pub struct VgaWriter { vmem: *mut u8, offset: usize, } impl VgaWriter { pub unsafe fn new(vmem: *mut u8) -> VgaWriter { let mut vga_writer = VgaWriter { vmem, offset: 0 }; v...
self.clear_line(i); } self.offset = self.offset.saturating_sub(lines * COLS); } } unsafe impl Send for VgaWriter {} impl Write for VgaWriter { fn write_str(&mut self, s: &str) -> core::fmt::Result { for c in s.chars() { if self.offset >= ROWS * COLS { ...
{ if lines == 0 { return; } let lines = core::cmp::min(lines, ROWS); if lines == ROWS { self.clear(); return; } unsafe { core::ptr::copy( self.vmem.offset((lines * COLS * 2) as isize), self....
identifier_body
vga.rs
//! VGA helpers use core::fmt::Write; use log::*;
const ROWS: usize = 25; const COLS: usize = 80; pub struct VgaWriter { vmem: *mut u8, offset: usize, } impl VgaWriter { pub unsafe fn new(vmem: *mut u8) -> VgaWriter { let mut vga_writer = VgaWriter { vmem, offset: 0 }; vga_writer.clear(); vga_writer } pub fn clear(&mut se...
use spin::Mutex;
random_line_split
vga.rs
//! VGA helpers use core::fmt::Write; use log::*; use spin::Mutex; const ROWS: usize = 25; const COLS: usize = 80; pub struct VgaWriter { vmem: *mut u8, offset: usize, } impl VgaWriter { pub unsafe fn new(vmem: *mut u8) -> VgaWriter { let mut vga_writer = VgaWriter { vmem, offset: 0 }; v...
(&self, _: &Metadata) -> bool { true } fn log(&self, record: &Record) { let mut writer = self.writer.lock(); let _ = writeln!( &mut writer, "[{}] {}: {}", level_as_string(record.level()), record.target(), record.args() ...
enabled
identifier_name
move-in-guard-1.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// 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. #![feature(box_synt...
// http://rust-lang.org/COPYRIGHT. //
random_line_split
move-in-guard-1.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ false }
identifier_body
move-in-guard-1.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let x: Box<_> = box 1; let v = (1, 2); match v { (1, _) if take(x) => (), (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` _ => (), } } fn take<T>(_: T) -> bool { false }
main
identifier_name
builtin-superkinds-self-type.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} impl <T: Sync> Foo for T { } //~^ ERROR the parameter type `T` may not live long enough fn main() { let (tx, rx) = channel(); 1193182.foo(tx); assert!(rx.recv() == 1193182); }
{ }
identifier_body
builtin-superkinds-self-type.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
use std::sync::mpsc::{channel, Sender}; trait Foo : Sync+'static { fn foo(self, mut chan: Sender<Self>) { } } impl <T: Sync> Foo for T { } //~^ ERROR the parameter type `T` may not live long enough fn main() { let (tx, rx) = channel(); 1193182.foo(tx); assert!(rx.recv() == 1193182); }
// Tests (negatively) the ability for the Self type in default methods // to use capabilities granted by builtin kinds as supertraits.
random_line_split
builtin-superkinds-self-type.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let (tx, rx) = channel(); 1193182.foo(tx); assert!(rx.recv() == 1193182); }
main
identifier_name
lib.rs
This module re-exports everything and includes free functions for all traits methods doing out-of-place modifications. * You can import the whole prelude using: ```.ignore use nalgebra::*; ``` The preferred way to use **nalgebra** is to import types and traits explicitly, and call free-functions using the `na::` pre...
, M: Translate<P>>(m: &M, p: &P) -> P { m.inv_translate(p) } /* * Rotation<V> */ /// Gets the rotation applicable by `m`. /// /// ```rust /// extern crate nalgebra as na; /// use na::{Vec3, Rot3}; /// /// fn main() { /// let t = Rot3::new(Vec3::new(1.0f64, 1.0, 1.0)); /// /// assert!(na::approx_eq(&na::...
v_translate<P
identifier_name