yaml-rust icon indicating copy to clipboard operation
yaml-rust copied to clipboard

Support unsigned type

Open jerry73204 opened this issue 6 years ago • 2 comments

I found .as_u64() is not available along with .as_i64(). It leaves me a bit inconvenience to parse the values manually. Is there a reason that it's included or is it not supported yet?

jerry73204 avatar Apr 20 '19 00:04 jerry73204

as YAML only have Integer (signed) type, so it should be parse as i64

chyh1990 avatar Sep 05 '19 08:09 chyh1990

Yes, I agree the idea to choose more a generalised type, but I think we can make things further.

The YAML spec states integer is arbitrary sized finite, so in I think there's no size limit and sign concept in mind. The spec later states it is parser's responsibility to reject or accept to convert to language type.

IMO, allowing {i,u}{8,16,32,64} basically does not violate the specification. We can simply move it ParseError whenever the Rust type cannot accept the value, and that would let users write less code with ? mark.

jerry73204 avatar Sep 05 '19 14:09 jerry73204