Open YoshikiTakashima opened 1 year ago
if you insert before let decoded_value = ...
the following debug line: println!("{buf:02x?}");
, you will see that encode_varint
has appended the bytes of the varint value 16384
to a buffer with twenty nul bytes:
---- encoding::test::decode_encode_roundtrip stdout ----
[00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 80, 7f]
That's how Vec<u8>
's implementation of bytes::BufMut
works. callingdecode_varint
on the slice view of that vec sees a nul byte first, which is a complete varint value 0
, and returns that.
so yes, that's expected
Running with 6375c4d0ea1ee133f6ca32fa21ac60db5e1168fa, the below test fails when pasted into
src/encoding.rs
. The decode seems to be returning 0.Is this expected?