From: Ian Jackson Date: Wed, 4 May 2022 22:17:34 +0000 (+0100) Subject: materials format: Make constants be of type VERSION X-Git-Tag: otter-1.1.0~276 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7022ce50ffd9327a6071a5db743b442aff60121e;p=otter.git materials format: Make constants be of type VERSION This lets them be more easily used in constructors etc. Signed-off-by: Ian Jackson --- diff --git a/src/materials-format.rs b/src/materials-format.rs index 223f0ad6..442fd738 100644 --- a/src/materials-format.rs +++ b/src/materials-format.rs @@ -13,9 +13,9 @@ pub struct Version(Raw); pub type Raw = u32; impl Version { - pub const MIN: Raw = 1; - pub const MAX: Raw = 1; - pub const CURRENT: Raw = 1; + pub const MIN: Version = Version(1); + pub const MAX: Version = Version(1); + pub const CURRENT: Version = Version::MAX; } // The version from before we invented this versioning scheme @@ -41,7 +41,7 @@ impl TryFrom for Version { type Error = Unsupported; #[throws(Unsupported)] fn try_from(raw: Raw) -> Self { - if raw >= Self::MIN && raw <= Self::MAX { + if raw >= *Self::MIN && raw <= *Self::MAX { Version(raw) } else { throw!(Unsupported(raw));