pub struct ArrayExtent {
pub value: usize,
pub source: ExtentSource,
pub origin: Origin<Expr>,
}Expand description
A fixed-size array’s extent: the number, the const identity when the source named one, and the spelling it was written with.
§Three facts, three consumers — and no ==
The three answer different questions, and deliberately no equality is provided, because there is no single one that could be right. A consumer projects the fact it actually needs:
| Question | Projection |
|---|---|
| is this the same type / the same converter? | Self::value |
| how does a C declaration spell it? | Self::origin.syntax, per occurrence |
which consts must reach the header as a #define? | Self::const_id |
A blanket == mixes them and is wrong under either reading: comparing
source makes [u8; A] differ from [u8; 4] when A == 4 — one Rust type
reported as two — while ignoring the spelling makes [u8; 4] equal
[u8; 0x04], whose retained syntax differs. Neither is type identity and
neither is spelling identity, so the choice belongs to whoever is asking.
§Note for a converter table
value being the type identity means several occurrences share one
converter, and their spellings differ. A shared converter therefore needs a
canonical Rust spelling chosen on purpose — the evaluated literal is the
obvious one — rather than whichever occurrence happened to populate a
deduplicated entry.
This lives on the use site — a field’s or parameter’s type — and never on anything keyed by type, for the same reason: two occurrences of one type may name the length differently, so a type-keyed table could only report whichever was stored last.
Fields§
§value: usizeThe evaluated length. The type identity: [u8; A] and [u8; 4] are one
Rust type when A == 4, and a destination language with no way to name a
Rust const needs the number.
source: ExtentSourceHow the length was addressed, so a C header can re-state
uint8_t tag[TAG_LEN] and know TAG_LEN must reach it.
origin: Origin<Expr>The length expression as written — 4, 0x04, TAG_LEN — and where it
came from. The spelling of this occurrence, which is what a declaration
re-emits; two occurrences of one type may differ here.
Implementations§
Trait Implementations§
Source§impl Clone for ArrayExtent
impl Clone for ArrayExtent
Source§fn clone(&self) -> ArrayExtent
fn clone(&self) -> ArrayExtent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Send for ArrayExtent
impl !Sync for ArrayExtent
impl Freeze for ArrayExtent
impl RefUnwindSafe for ArrayExtent
impl Unpin for ArrayExtent
impl UnsafeUnpin for ArrayExtent
impl UnwindSafe for ArrayExtent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more