Closed 17dec closed 4 years ago
Yeah, I think that saturating adds are the right solution here. I'll fix this quickly and push out 0.3.1, but long term, it was a mistake to make Value have a MAX_DEPTH of usize::max_value()
(it should actually have been 0, following the doc comment in encoding.rs
.
That's a breaking change, though, so it will need to be fixed in 0.4
Could you test using the latest master? If it works for you, I'll release it as 0.3.1.
Thanks!
Tested & working.
Thanks for the quick fix!
Easiest to illustrate with an example, attempting to encode an empty
Vec<Value>
Results in a compile error:
Which I suspect is due to
Value::MAX_DEPTH
being the max_usize. A saturating add would be ideal in this case, but using a slightly lowerMAX_DEPTH
with room for a bunch parent containers may work, too.