bincode-org / bincode

A binary encoder / decoder implementation in Rust.
MIT License
2.63k stars 265 forks source link

bincode::de::Deserializer::with_reader() doesn't seem to work #693

Closed mwiniarski closed 4 months ago

mwiniarski commented 7 months ago
#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct Wrapper<'a> {
    s: &'a str,
}

let w = Wrapper { s: "W" };

let cursor = Cursor::new(bincode::serialize(&w).unwrap());
let op = options().with_fixint_encoding().allow_trailing_bytes();
let mut des = bincode::de::Deserializer::with_reader(cursor, op);

let _: Wrapper = serde::Deserialize::deserialize(&mut des).unwrap(); // Fails here

The error messages says: panicked at 'called `Result::unwrap()` on an `Err` value: Custom("invalid type: string \"W\", expected a borrowed string")'

Interestingly changing the from_reader + cursor approach to from_slice works fine

stale[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.