`HybridUint` for mix-match `Uint` in-struct
This could be a variant of "worst case" where the Limbs are MaybeUninit or heapless::Vec which uses MaybeUninit behind the scenes.
This would allow easier portability between BoxedUint and no-alloc variant without re-writing into fixed sizes whilst avoiding global alloc ? e.g. here:
- https://github.com/RustCrypto/RSA/pull/636#discussion_r2715157271
Say there is:
```rust
struct Foo {
a: HeaplessUint<2>, // U64/U128 Max
b: HeaplessUint<1>, // U32/64 Max
}
```
It would be more memory efficient than:
```rust
struct Foo<U: Unsigned> {
a: U
b: U
}
```
Where used `U` can be `U2048` | `U4096` etc. in case which it takes double the space vs optimising through worst case.
And more flexible than relying on type-aliases:
```rust
struct Foo {
a: U2048,
b: U128,
}
```
Arguably it is just another form of `Uint<Limbs>` but Heapless is essentially optimizing through `[MaybeUninit<Limb>; N]`
8 条评论