Closed 6d7a closed 11 months ago
If you have a minute, @XAMPPRocky, could you let me know if there is a more elegant way of handling the two cases in to_vec?
If I'm reading the code right, there's only one spot where it's true and the rest are false, so I would just make a second function the pad_left case. There's no reason AFAICT that it has to be in to_vec.
Thanks, I was actually thinking more about the repeated for loop. I like the extra parameter in to_vec
, because it makes it clear where padding will be added for all cases.
I'm still not sure I see the benefit to it being one function rather than two functions? I think two functions is clearer, looking at the callsite it's not clear what the boolean does.
The workaround
to_vec
function insrc/per
works fine in all cases but when decoding non-negative binary integers. To be read correctly into aBigUint
, the bitslice needs to be padded at the start. I added an additional parameter to specify where padding should be inserted when converting the bitslice toVec<u8>
.If you have a minute, @XAMPPRocky, could you let me know if there is a more elegant way of handling the two cases in
to_vec
?Thanks