summaryrefslogtreecommitdiffstats
path: root/vendor/zerovec/src/ule/plain.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/zerovec/src/ule/plain.rs')
-rw-r--r--vendor/zerovec/src/ule/plain.rs19
1 files changed, 2 insertions, 17 deletions
diff --git a/vendor/zerovec/src/ule/plain.rs b/vendor/zerovec/src/ule/plain.rs
index 0b1bbb441..49455d45f 100644
--- a/vendor/zerovec/src/ule/plain.rs
+++ b/vendor/zerovec/src/ule/plain.rs
@@ -7,10 +7,7 @@
use super::*;
use crate::ZeroSlice;
-use core::{
- mem,
- num::{NonZeroI8, NonZeroU8},
-};
+use core::num::{NonZeroI8, NonZeroU8};
/// A u8 array of little-endian data with infallible conversions to and from &[u8].
#[repr(transparent)]
@@ -100,19 +97,7 @@ macro_rules! impl_const_constructors {
let len = bytes.len();
#[allow(clippy::modulo_one)]
if len % $size == 0 {
- unsafe {
- // Most of the slice manipulation functions are not yet const-stable,
- // so we construct a slice with the right metadata and cast its type
- // https://rust-lang.github.io/unsafe-code-guidelines/layout/pointers.html#notes
- //
- // Safety:
- // * [u8] and [RawBytesULE<N>] have different lengths but the same alignment
- // * ZeroSlice<$base> is repr(transparent) with [RawBytesULE<N>]
- let [ptr, _]: [usize; 2] = mem::transmute(bytes);
- let new_len = len / $size;
- let raw = [ptr, new_len];
- Ok(mem::transmute(raw))
- }
+ Ok(unsafe { Self::from_bytes_unchecked(bytes) })
} else {
Err(ZeroVecError::InvalidLength {
ty: concat!("<const construct: ", $size, ">"),