let path = "./assets/manifest.webmanifest";
let manifest: Manifest = fs::read_to_string(path)?.parse()?;
This not only looks nice, but it removes the need for consumers to import serde and serde_json as peer dependencies to perform parsing.
Guide-level explanation
By implementing str::FromStr conversions can be done using .parse()?. We should add an example for this too to the README under ## Examples using a heading like: ### Read Manifest from Disk.
Reference-level explanation
The from_str method should wrap around serde_json::from_str()? .
Drawbacks
None.
Rationale and alternatives
Alternatively we could implement TryInto to replace .parse()? with .try_into(). But that's currently not available on stable yet, so we can add it once it is.
Feature Request
Summary
Implement the
std::str::fromStr
trait forManifest
.Motivation
It'd be great if the following could work:
This not only looks nice, but it removes the need for consumers to import
serde
andserde_json
as peer dependencies to perform parsing.Guide-level explanation
By implementing
str::FromStr
conversions can be done using.parse()?
. We should add an example for this too to the README under## Examples
using a heading like:### Read Manifest from Disk
.Reference-level explanation
The
from_str
method should wrap aroundserde_json::from_str()?
.Drawbacks
None.
Rationale and alternatives
Alternatively we could implement
TryInto
to replace.parse()?
with.try_into()
. But that's currently not available on stable yet, so we can add it once it is.Unresolved Questions
None.