dtolnay / erased-serde

Type-erased Serialize, Serializer and Deserializer traits
Apache License 2.0
709 stars 36 forks source link

Broken #54

Closed Yuri6037 closed 2 years ago

Yuri6037 commented 2 years ago

This crate is completely broken.

Consider the following code:

            let options = bincode::DefaultOptions::new()
                .with_fixint_encoding()
                .allow_trailing_bytes();
            let mut v: Vec<u8> = Vec::new();
            let serializer = bincode::Serializer::new(v, options);
            let serializer = erased_serde::Serializer::erase(serializer);

This results in 2 errors:

error[E0277]: the trait bound `bincode::Serializer<Vec<u8>, WithOtherTrailing<WithOtherIntEncoding<DefaultOptions, FixintEncoding>, AllowTrailing>>: erased_serde::private::serde::Serializer` is not satisfied
error[E0782]: trait objects must include the `dyn` keyword

The first error is very confusing and points to a module named private which does not exist in the docs.

Yuri6037 commented 2 years ago

Ok the syntax has largely changed from the doc I've read; it now has to be

let serializer = <dyn erased_serde::Serializer>::erase(&mut serializer);