-
-
Notifications
You must be signed in to change notification settings - Fork 795
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
Cannot derive Deserialize for a type that contains a type which contains a static reference #1712
Comments
impl<'de> Deserialize<'de> for Foo
where
'de: 'static so that additional constraint would need to be provided on use serde::Deserialize;
#[derive(Deserialize)]
pub struct Foo(&'static str);
#[derive(Deserialize)]
#[serde(bound(deserialize = "'de: 'static"))]
pub struct Bar(Foo); |
Sorry for thread necro, but I find that solution emits the warning "unnecessary lifetime parameter Worse, due to rust-lang/rust#96956, the warning un-silenceable. Even |
@bblum if you are desperate for a quick fix you can do: #[derive(Deserialize, Debug)]
pub struct Bar(
#[serde(bound(deserialize = "Foo: Deserialize<'de>"))]
Foo
); |
As mentioned in the code comment, the list of valid registration authorities must be sorted, which allows us to look for the index with binary search. We ensure this with a unit-test. An alternative that was explored was to have a `&'static str` field. However, this leads to problems for deserializer lifetimes, and the workaround from [1] would need to be applied to numerous types. [1] serde-rs/serde#1712
Notably,
#[serde(borrow)]
, as suggested by #1417, doesn't work:Related, but seemingly different:
The text was updated successfully, but these errors were encountered: