-
-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lifetime bound error when deriving Encode
and Decode
with v2.0.0-rc.3
#646
Comments
I have the same issue, specifically when deriving Minimal reproducible example that does not compile using RC-3: use bincode::Encode;
#[derive(Encode)]
struct MyStruct<'a> {
vec_of_str: Vec<&'a str>,
} Compilation error:
|
I am encountering the same problem. I tried a good bit of types, and I got that any simple slice is going to fail:
where |
Have something similar: we have a newtype wrapping over a Update: does compile with the version from current trunk (73258a7). Issue seems to be fixed (in my case) from 08556ca onwards. code #[derive(Clone, Debug, Default)]
#[repr(transparent)]
pub struct BincodeVec<T, const N: usize>(pub Vec<T, N>); impl<T: Encode, const N: usize> Encode for BincodeVec<T, N> {
fn encode<E: bincode::enc::Encoder>(&self, encoder: &mut E) -> Result<(), EncodeError> {
self.0.as_slice().encode(encoder)
}
} compilation output
|
Minified example:
Throws:
I've managed to reproduce the same error when replacing
Vec<B>
with e.g.[B; 1]
, though the error is only thrown forDecode
.I don't yet know the codebase but could this be related to #635?
Thanks!
Edit: I've done a little further digging and it would seem that there is a
'static
bound introduced by the use ofTypeId
for both[T; N]
andVec<T>
(amongst a few others). Although it likely won't be an issue in a lot of cases, this might end up being impractical for types that might want to carry references?The text was updated successfully, but these errors were encountered: