Skip to content

Commit

Permalink
from_str for Pep732Metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
blueraft committed Aug 10, 2024
1 parent 1f89782 commit 77befe0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/uv-scripts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ pub struct Pep723Metadata {
pub raw: String,
}

impl Pep723Metadata {
impl FromStr for Pep723Metadata {
type Err = Pep723Error;
/// Parse `Pep723Metadata` from a raw TOML string.
pub fn from_string(raw: String) -> Result<Self, toml::de::Error> {
let metadata = toml::from_str(&raw)?;
Ok(Pep723Metadata { raw, ..metadata })
fn from_str(raw: &str) -> Result<Self, Self::Err> {
let metadata = toml::from_str(raw)?;
Ok(Pep723Metadata {
raw: raw.to_string(),
..metadata
})
}
}

Expand Down

0 comments on commit 77befe0

Please sign in to comment.