@@ -40,19 +40,19 @@ use super::value::Value;
4040/// `Number`, `String` and `Container`. They have three different decode methods.
4141/// 1. `Null`, `True` and `False` can be obtained by `JEntry`, no extra work required.
4242/// 2. `Number` and `String` has related `RawData`, `JEntry` store the length
43- /// or offset of this data, the `Value` can be read out and then decoded.
43+ /// or offset of this data, the `Value` can be read out and then decoded.
4444/// 3. `Container` is actually a nested `Array` or `Object` with the same structure,
45- /// `JEntry` store the length or offset of the lower-level `Header`,
46- /// from where the same decode process can begin.
47-
48- /// `RawData` is the encoded `Value`.
49- /// `Number` is a variable-length `Decimal`, store both int and float value.
50- /// `String` is the original string, can be borrowed directly without extra decode.
51- /// `Array` and `Object` is a lower-level encoded `JSONB` value.
52- /// The upper-level doesn't care about the specific content.
53- /// Decode can be executed recursively.
54-
55- /// Decode `JSONB` Value from binary bytes.
45+ /// `JEntry` store the length or offset of the lower-level `Header`,
46+ /// from where the same decode process can begin.
47+ ///
48+ /// `RawData` is the encoded `Value`.
49+ /// `Number` is a variable-length `Decimal`, store both int and float value.
50+ /// `String` is the original string, can be borrowed directly without extra decode.
51+ /// `Array` and `Object` is a lower-level encoded `JSONB` value.
52+ /// The upper-level doesn't care about the specific content.
53+ /// Decode can be executed recursively.
54+ ///
55+ /// Decode `JSONB` Value from binary bytes.
5656pub fn from_slice ( buf : & [ u8 ] ) -> Result < Value < ' _ > , Error > {
5757 let mut decoder = Decoder :: new ( buf) ;
5858 match decoder. decode ( ) {
@@ -122,7 +122,7 @@ impl<'a> Decoder<'a> {
122122 }
123123 NUMBER_TAG => {
124124 let offset = jentry. length as usize ;
125- let n = Number :: decode ( & self . buf [ ..offset] ) ;
125+ let n = Number :: decode ( & self . buf [ ..offset] ) ? ;
126126 self . buf = & self . buf [ offset..] ;
127127 Ok ( Value :: Number ( n) )
128128 }
0 commit comments