Skip to content

HybridUint for mix-match Uint in-struct #1148

@pinkforest

Description

@pinkforest

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:

Say there is:

struct Foo {
  a: HeaplessUint<2>, // U64/U128 Max
  b: HeaplessUint<1>, // U32/64 Max
}

It would be more memory efficient than:

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:

struct Foo {
  a: U2048,
  b: U128,
}

Arguably it is just another form of Uint<Limbs> but Heapless is essentially optimizing through [MaybeUninit<Limb>; N]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions