bytemuck changelogpod_saturating feature, which adds Pod impls for Saturating<T> when T is already Pod.bytemuck_derive dependency from 1.4.0 to 1.4.1 to avoid a bug if you have a truly ancient cargo.lock file sitting around.Send and Sync impls to BoxBytes.Pod and Zeroable for core::arch::{x86, x86_64}::__m512, __m512d and __m512i without nightly. Requires Rust 1.72, and is gated through the avx512_simd cargo feature.must_cast_mut and must_cast_slice_mut in const contexts. Requires Rust 1.83, and is gated through the must_cast_extra cargo feature.maybe_const_fn macro that allows defining some function to be const depending upon some cfg predicate.Arc and Rc. Requires Rust 1.82TransparentWrapper impls for core::cmp::Reverse and core::num::Saturating.fill_zeroes calls to write_bytes#[track_caller] attribute to functions which may panic.latest_stable_rust cargo feature, which is a blanket feature that turns all other features on that are both sound and compatible with Stable rust.#[repr(C)] to the union Transmute<A, B> type that's used internally for most of the transmutations.must_cast versions of the by-value and by-ref casts be const. The mut ref cast is unaffected for now (mut references aren't yet stable in const fn). This increases the MSRV of using that particular feature from 1.57 to 1.64.BoxBytes could attempt to free a dangling pointer if the Layout is zero sized. This type was introduced in 1.14.1, so that version and the others up to and including 1.16.1 are now yanked for safety.nightly_float Cargo feature. This activates the f16 and f128 nightly features, and then provides Zeroable and Pod impls for those types.const_zeroed feature (MSRV 1.75) which puts a zeroed fn at the crate root. This is just like the Zeroable::zeroed method, but as a const fn.This primarily relaxes the bounds on a From impl.
Previously:
impl<T: NoUninit> From<Box<T>> for BoxBytes
Now:
impl<T: ?Sized + sealed::BoxBytesOf> From<Box<T>> for BoxBytes
All related functions and methods are similarly updated.
We believe this to be backwards compatible with all previous uses, and now BoxBytes can be converted to/from more types than before.
nightly_stdsimd feature. This is needed as of (approximately) Nightly 2024-02-06 and later, because the Nightly feature was changed.write_zeroes and fill_zeroes functions: Writes (to one) or fills (a slice) zero bytes to all bytes covered by the provided reference. If your type has padding, this will even zero out the padding bytes.align_offset feature: causes pointer alignment checks to use the align_offset pointer method rather than as-casting the pointer to usize. This may improve codegen, if the compiler would have otherwise thought that the pointer address escaped. No formal benchmarks have been done either way.must_cast feature: Adds must_* family of functions. These functions will fail to compile if the cast requested can't be statically known to succeed. The error messages can be kinda bad when this happens, but eliminating the possibility of a runtime error might be worth it to you.AnyBitPattern on pod_collect_to_vec, allowing you to pod collect vecs of char into vecs of u32, or whatever.bytemuck_derive-1.4.0Arc or not based on the target_has_atomic config. Previously, some targets that have allocation but not atomics were getting errors. This raises the MSRV of the extern_crate_alloc feature to 1.60, but opt-in features are not considered to be hard locked to 1.34 like the basic build of the crate is.try_pod_read_unaligned bug that made it always fail unless the target type was exactly pointer sized in which case UB could happen. The CheckedBitPattern::is_valid_bit_pattern was being asked to check that a reference to the pod value was a valid bit pattern, rather than the actual bit pattern itself, and so the check could in some cases be illegally bypassed.bytemuck_derive version because of a regression in how it handled align(N) attributes.bytemuck_derive dependency, which is in turn caused by a mixup in the minimum version of syn that bytemuck_derive uses. See Issue 122. There's not any specific “new” API as you might normally expect from a minor version bump.Display, which the error types normally support, except on SPIR-V targets (which run on the GPU and don't have text formatting).wrap_box and peel_box to the TransparentWrapperAlloc trait. Default impls of these functions are provided, and (as usual with the transparent trait stuff) you should not override the default versions.ZeroableInOption and PodInOption traits. These are for types that are Zeroable or Pod when in an option, but not on their own. We provide impls for the various “NonZeroINTEGER” types in core, and if you need to newtype a NonZero value then you can impl these traits when you use repr(transparent).bytemuck_derive dependency version from 1.0 to 1.1. The fact that bytemuck and bytemuck_derive are separate crates at all is an unfortunate technical limit of current Rust, woe and calamity.NoUninit, AnyBitPattern, and CheckedBitPattern traits. This allows for a more fine-grained level of detail in what casting operations are allowed for a type. Types that already implement Zeroable and Pod will have a blanket impl for these new traits. This is a “preview” of the direction that the crate will probably go in the eventual 2.0 version. We're still waiting on Project Safe Transmute for an actual 2.0 version of the crate, but until then please enjoy this preview.union types in the derive macros. I still don't know how any of the proc-macro stuff works at all, so please direct questions to her.try_pod_read_unaligned and pod_read_unaligned let you go from &[u8] to T:Pod without worrying about alignment.portable_simd language extension under the nightly_portable_simd cargo feature. As the name implies, this is an experimental crate feature and it's not part of the semver contract. All it does is add the appropriate Zeroable and Pod impls.TransparentWrapper in 1.6, can cause a double-drop if used with types that impl Drop. The fix was simply to add a ManuallyDrop layer around the value before doing the transmute_copy that is used to wrap/peel. While this fix could technically be backported to the 1.6 series, since 1.7 is semver compatible anyway the 1.6 series has simply been yanked.Pod. More specifically, ptr as usize is not the same operation as calling transmute::<_, usize>(ptr).Pod impls for *const T, *mut T, and Option<NonNull<T> are now gated behind the unsound_ptr_pod_impl feature, which is off by default.;, so PR 69 actually got things working on SPIR-V.cargo upload goof! ignore this one.
TransparentWrapper trait now has more methods. More ways to wrap, and now you can “peel” too! Note that we don't call it “unwrap” because that name is too strongly associated with the Option/Result methods. Thanks to LU15W1R7H for doing PR 58min_const_generics crate feature. zakarumych got the work started in PR 59, and chorman0773 finished off the task in PR 63bytes_of failing on zero sized types. PR 53pod_collect_to_vec, which will gather a slice into a vec, allowing you to change the pod type while also safely ignoring alignment. PR 50try_zeroed_box stack overflow for large values at low optimization levels. PR 43Pod, TransparentWrapper, Zeroable!! Everyone has been waiting for this one folks! It‘s a big deal. Just enable the derive cargo feature and then you’ll be able to derive the traits on your types. It generates all the appropriate tests for you.zeroable_maybe_uninit feature now adds a Zeroable impl to the MaybeUninit type. This is only behind a feature flag because MaybeUninit didn't exist back in 1.34.0 (the minimum rust version of bytemuck).Apache-2.0 OR MIT license as well as the previous Zlib license #24.try_zeroed_slice_box function #10. zeroed_slice_box is also available.offset_of! macro now supports a 2-arg version. For types that impl Default, it'll just make an instance using default and then call over to the 3-arg version.PodCastError type now supports Hash and Display. Also if you enable the extern_crate_std feature then it will support std::error::Error.TransparentWrapper<T> impl for core::num::Wrapper<T>.try_from_bytes and try_from_bytes_mut when the input isn't aligned has been corrected from being AlignmentMismatch (intended for allocation casting only) to TargetAlignmentGreaterAndInputNotAligned.extern_crate_alloc feature was used. Still, this is yanked, sorry.from_bytes, from_bytes_mut, try_from_bytes, and try_from_bytes_mut (PR Link)