Lokathor / bytemuck

A crate for mucking around with piles of bytes
https://docs.rs/bytemuck
Apache License 2.0
697 stars 77 forks source link

Make must_cast by-value and by-shared-ref functions const #261

Closed zachs18 closed 1 month ago

zachs18 commented 1 month ago

(but not by-mut-ref, since that's not stable).

This would raise the MSRV of the must_cast feature from 1.57.0 to 1.64.0 (when slice_from_raw_parts was made const-stable). Alternately, this could be added as a new feature (const_must_cast?) with its own MSRV[^1].

The new arm of the transmute! macro is to work around borrowing a generic type in const-eval not being allowed on stable, since the borrowed type could have interior mutabilty. Transmuting via union does not have this issue, since no borrowing occurs.

[^1]: must_cast and must_cast_ref's MSRV is at least 1.61.0, when const_fn_trait_bound was stabilized. must_cast_slice's MSRV is at least 1.64.0, as mentioned.

zachs18 commented 1 month ago

(I believe the CI failures are due to https://github.com/rust-lang/rust/issues/128808)

Lokathor commented 1 month ago

Because it's an optional feature and because 1.64 is quite old at this point i think we can ignore the msrv.

I'd like to probably wait on CI if the nightly rust bug is going to only be a day or two

zachs18 commented 1 month ago

(Current nightly has the fix; force-pushed for CI)

Lokathor commented 3 weeks ago

Released bytemuck-v1.17.0