* Change #![allow(clippy::missing_docs_in_private_items)] to #[allow(clippy::missing_docs_in_private_items)], also rustfmt went wild
* fix for 1.34 building.
* clippy be quiet
* derive changelog.
* chore: Release bytemuck_derive version 1.7.0
* Change #![allow(clippy::missing_docs_in_private_items)] to #[allow(clippy::missing_docs_in_private_items)], also rustfmt went wild
* fix for 1.34 building.
* clippy be quiet
Note that the ergonomics are still not great, since `NoUninit` is also required to use `derive(ByteEq, ByteHash)`, and `derive(NoUninit)` doesn't support generics,
but that *explicitly* doesn't support generics, instead of silently ignoring generics like `derive(ByteEq, ByteHash)` used to, so this is strictly an improvement.
* Explicitly document that pod_read_unaligned and try_pod_read_unaligned don't panic on unallowed reads
Their names make that reasonably clear already, but it doesn't hurt to
be explicit. Also, when choosing between `*from_bytes(x)` and
`pod_read_unaligned(x)`, it's good to have a clearly documented
criterion.
* Cosmetic doc changes
Add a couple of missing links, add a missing "like" (consistent with
other similar sentences).
* Remove redundant link
The redundant link emits a warning in `cargo doc`.
* simplify `ToTokens` impl for `Representation`
Instead of collecting the representation and modifier into `Option`s
and determining whether a comma is needed manually, we can use the
`Puncutuated` struct which handles commas automatically.
This will also make emitting the `align` modifier in the future easier.
* emit alignment modifier
This is required for correctly implementing `CheckedBitPattern` because
we need the layout of the type and its `Bits` type to have the same
layout.
* add unit test for `#[repr]` parsing
* allow multiple alignment modifiers
According to RFC #1358, if multiple alignment modifiers are specified,
the resulting alignment is the maximum of all alignment modifiers.
* actually return the error we just created
* factor out the integer Repr's into their own type
This is a preparation step for adding support for `#[repr(C, int)]`.
* allow parsing `#[repr(C, int)]`
This can be used on enums with fields.
* derive `CheckedBitPattern` for enums with fields
The implementation mostly mirrors the desugaring described at
https://doc.rust-lang.org/reference/type-layout.html
* add comments and rename some idents
* update error message
* update docs for `CheckedBitPattern` derive
* add new nested test case, change generated type naming scheme
* fix wrong comment
* small nit
---------
Co-authored-by: Gray Olson <gray@grayolson.com>
* Add functions for writing zeroed bytes to `&mut impl Zeroable` and `&mut [impl Zeroable]`
* Support `T: !Copy` in `fill_zero`/`write_zero`
* Zero bytes in the drop guard for write_zero
* Update src/lib.rs
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
---------
Co-authored-by: Lokathor <zefria@gmail.com>
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
`from_integer` and `into_integer` are usually provided by the trait's
default implementation. We override this implementation because it goes
through `transmute_copy`, which can lead to inefficient assembly as seen
in https://github.com/Lokathor/bytemuck/issues/175 .
- new feature `nightly_docs` enables `doc_cfg` unstable feature that allows showing explicit dependencies on features.
- new cargo alias `nightly_docs` for a more convenient local documentation build `cargo +nightly nightly_docs --open`.
- annotate exported items and implementations depending on some feature with the corresponding `doc(cfg())` attribute.
- add the `nightly_docs` feature to the `[package.metadata.docs.rs]` section.