Skip to content

Commit b152e6c

Browse files
committed
forgot with_size_unzeroed
1 parent 9c7730f commit b152e6c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "byteview"
33
description = "Thin, immutable zero-copy slice type"
44
license = "MIT OR Apache-2.0"
5-
version = "0.9.0"
5+
version = "0.9.1"
66
edition = "2021"
77
rust-version = "1.81"
88
readme = "README.md"

src/byteview.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl ByteView {
268268
// NOTE: We can use _unzeroed to skip zeroing of the heap allocated slice
269269
// because we receive the `len` parameter
270270
// If the reader does not give us exactly `len` bytes, `read_exact` fails anyway
271-
let mut s = Self::with_size_unzeroed(len);
271+
let mut s = unsafe { Self::with_size_unzeroed(len) };
272272
{
273273
let mut builder = Mutator(&mut s);
274274
reader.read_exact(&mut builder)?;
@@ -365,7 +365,7 @@ impl ByteView {
365365
/// Panics if the length does not fit in a u32 (4 GiB).
366366
#[doc(hidden)]
367367
#[must_use]
368-
pub fn with_size_unzeroed(slice_len: usize) -> Self {
368+
pub unsafe fn with_size_unzeroed(slice_len: usize) -> Self {
369369
let view = if slice_len <= INLINE_SIZE {
370370
Self {
371371
trailer: Trailer {
@@ -430,7 +430,7 @@ impl ByteView {
430430
pub fn new(slice: &[u8]) -> Self {
431431
let slice_len = slice.len();
432432

433-
let mut view = Self::with_size_unzeroed(slice_len);
433+
let mut view = unsafe { Self::with_size_unzeroed(slice_len) };
434434

435435
if view.is_inline() {
436436
// SAFETY: We check for inlinability

0 commit comments

Comments
 (0)