Skip to content
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

[Bug] de::from_str has overly strict generic restrictions. #739

Closed
Embers-of-the-Fire opened this issue Jun 1, 2024 · 1 comment
Closed

Comments

@Embers-of-the-Fire
Copy link

Summary

Currently, toml::de::from_str has a signature like this:

pub fn from_str<T>(s: &'_ str) -> Result<T, Error>
where
    T: serde::de::DeserializeOwned, // note this
{
    T::deserialize(Deserializer::new(s))
}

Based on both serde's suggestion and the actual method implementation, this should not be DeserializeOwned. This issue has limited impact in practical use, but for some generic implementations may lead to more complex signatures and thus cascading contagion.

Solution

Simply change the DeserializeOwned into Deserialize<'de>.

@epage
Copy link
Member

epage commented Jun 1, 2024

Closing as this is a duplicate of #490

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants