chiark / gitweb /
materials format: Make constants be of type VERSION
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 4 May 2022 22:17:34 +0000 (23:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 4 May 2022 22:17:34 +0000 (23:17 +0100)
This lets them be more easily used in constructors etc.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/materials-format.rs

index 223f0ad677e1af016b52cd3d229842a8a1bf7e15..442fd7381f013bf9286db6b1a010e27f349aebe4 100644 (file)
@@ -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<Raw> 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));