Sha256: 9564fcf47000e70d521b31518e205c8e6ee09b7410fb1eb1e452721757ff54ba
Contents?: true
Size: 466 Bytes
Versions: 29
Compression:
Stored size: 466 Bytes
Contents
use super::{mystd::io::Read, File}; use alloc::vec::Vec; use core::ops::Deref; pub struct Mmap { vec: Vec<u8>, } impl Mmap { pub unsafe fn map(mut file: &File, len: usize) -> Option<Mmap> { let mut mmap = Mmap { vec: Vec::with_capacity(len), }; file.read_to_end(&mut mmap.vec).ok()?; Some(mmap) } } impl Deref for Mmap { type Target = [u8]; fn deref(&self) -> &[u8] { &self.vec[..] } }
Version data entries
29 entries across 29 versions & 1 rubygems