Debian Codegraph @

debian/rust-vendor/bitvec/doc/mem/BitElement.md

raw
1 # Unified Element Constructor
2
3 This type is a hack around the fact that `Cell` and `AtomicUN` all have
4 `const fn new(val: Inner) -> Self;` constructors, but the numberic fundamentals
5 do not. As such, the standard library does not provide a unified construction
6 syntax to turn an integer fundamental into the final type.
7
8 This provides a `const fn BitElement::<_>::new(R) -> Self;` function,
9 implemented only for the `BitStore` implementors that the crate provides, that
10 the constructor macros can use to turn integers into final values without using
11 [`mem::transmute`]. While `transmute` is acceptable in this case (the types are
12 all `#[repr(transparent)]`), it is still better avoided where possible.
13
14 As this is a macro assistant, it is publicly exposed, but is not public API. It
15 has no purpose outside of the crate’s macros.
16
17 [`mem::transmute`]: core::mem::transmute.