From 1fb6b1b85654076ebc717f26ec0fa8444793396b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 4 May 2022 22:52:24 +0100 Subject: [PATCH] materials format: String parsing Signed-off-by: Ian Jackson --- src/materials-format.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/materials-format.rs b/src/materials-format.rs index 84abe90b..9bdf634c 100644 --- a/src/materials-format.rs +++ b/src/materials-format.rs @@ -49,6 +49,16 @@ impl TryFrom for Version { } } +impl FromStr for Version { + type Err = VersionError; + #[throws(VersionError)] + fn from_str(s: &str) -> Version { + let v: Raw = s.parse() + .map_err(|_| MFVE::Other("could not parse as ingeger"))?; + v.try_into()? + } +} + macro_rules! impl_compar_i32 { { $( impl $Trait:ident { fn $method:ident -> $out:ty; } -- 2.30.2