chiark / gitweb /
zcoord: Move from_str impl to be (only) in FromStr impl
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 30 Mar 2022 23:55:41 +0000 (00:55 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 30 Mar 2022 23:59:17 +0000 (00:59 +0100)
Suggested by clippy.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
base/zcoord.rs

index 7c7847a2b07097c3cc38fc86c336f0e201afdf4a..ebdeda6f10e03523750a31d788ac60447b55eb5e 100644 (file)
@@ -554,7 +554,10 @@ impl TryFrom<&str> for ZCoord {
 impl FromStr for ZCoord {
   type Err = ParseError;
   #[throws(ParseError)]
-  fn from_str(s: &str) -> ZCoord { ZCoord::from_str(s)? }
+  fn from_str(s: &str) -> ZCoord {
+    let tail = ZCoord::checked(s)?;
+    ZCoord::alloc_copy(tail).unwrap()
+  }
 }
 
 //---------- construction of ZCoord contents ---------
@@ -598,12 +601,6 @@ impl ZCoord {
   pub fn check_str(s: &str) {
     Self::checked(s)?;
   }
-
-  #[throws(ParseError)]
-  pub fn from_str(s: &str) -> Self {
-    let tail = ZCoord::checked(s)?;
-    ZCoord::alloc_copy(tail).unwrap()
-  }
 }
 
 impl TryFrom<&Mutable> for ZCoord {