I open this as an issue as I'm sure it'll need discussion.
Problem:
I need 1 << x where x is ~256-2000, but variable and specified by the caller. I want either:
- The caller to pass me
T = U2048
- The caller to pass me
T = BoxedUint
My issue is if I get T = BoxedUint, I cannot get a 2048-bit BoxedUint without using BoxedUint::one_with_precision, Resize, or BoxedUint::one_like. The first two are specific to BoxedUint. The third is portable with Uint, but would require the caller pass in one_shl_x so that I had the value to 'be like'.
Ideally, I'd have a MaybeResize::resize(One::one(), x) which for fixed types, does nothing, but for BoxedUint, does call BoxedUint::resize.
Are we fine with MaybeResize as a complement to Resize for this purpose? Is there some function I'm missing? Should we instead have One::one_with_precision?
As an absolute hack, I can simply have an RNG which always outputs 0 and abuse RandomBits for this today. As an oddity, RandomBits::try_random_bits_with_precision appears to be the only trait method today which is implemented for both Uint and BoxedUint, while supporting a precision argument (which is discarded if inapplicable). That at least suggests precedent for this...
I open this as an issue as I'm sure it'll need discussion.
Problem:
I need
1 << xwherexis ~256-2000, but variable and specified by the caller. I want either:T = U2048T = BoxedUintMy issue is if I get
T = BoxedUint, I cannot get a 2048-bitBoxedUintwithout usingBoxedUint::one_with_precision,Resize, orBoxedUint::one_like. The first two are specific toBoxedUint. The third is portable withUint, but would require the caller pass inone_shl_xso that I had the value to 'be like'.Ideally, I'd have a
MaybeResize::resize(One::one(), x)which for fixed types, does nothing, but forBoxedUint, does callBoxedUint::resize.Are we fine with
MaybeResizeas a complement toResizefor this purpose? Is there some function I'm missing? Should we instead haveOne::one_with_precision?As an absolute hack, I can simply have an RNG which always outputs
0and abuseRandomBitsfor this today. As an oddity,RandomBits::try_random_bits_with_precisionappears to be the onlytraitmethod today which is implemented for bothUintandBoxedUint, while supporting a precision argument (which is discarded if inapplicable). That at least suggests precedent for this...