You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 15, 2025. It is now read-only.
// raw codeuse bincode::Encode;#[derive(Encode)]structFoo<T>{inner:T,}// current derive macro output, and it's failed to compile!use bincode::Encode;structFoo<T>{inner:T,}impl<T> bincode::enc::EncodeforFoo<T>{fnencode<E: bincode::enc::Encoder>(&self,mutencoder:E,) -> core::result::Result<(), bincode::error::EncodeError>{
bincode::enc::Encode::encode(&self.inner,&mut encoder)?;Ok(())}}// what it should ouputuse bincode::Encode;structFoo<T>{inner:T,}impl<T:Encode> bincode::enc::EncodeforFoo<T>{fnencode<E: bincode::enc::Encoder>(&self,mutencoder:E,) -> core::result::Result<(), bincode::error::EncodeError>{
bincode::enc::Encode::encode(&self.inner,&mut encoder)?;Ok(())}}
The current macro needs the type parameter T be T: Encode. But in Rust, the latter one is more common.
I think most of derive macros in Rust ecosystem like serde::Serialize do the latter way.
So it's better for users when bincode's derive macros do it so.