From: Ian Jackson Date: Wed, 4 May 2022 21:52:24 +0000 (+0100) Subject: materials format: String parsing X-Git-Tag: otter-1.1.0~278 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=1fb6b1b85654076ebc717f26ec0fa8444793396b;p=otter.git materials format: String parsing Signed-off-by: Ian Jackson --- 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; }