From 70f3a6adb5c817c4505ce3e97374f30adecbf52d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 31 Mar 2022 01:34:27 +0100 Subject: [PATCH] clippy: Miscellaneous minor changes Signed-off-by: Ian Jackson --- src/gamestate.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gamestate.rs b/src/gamestate.rs index aba70d14..7571c1b6 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -298,6 +298,7 @@ pub struct UniqueGenGen<'g> { } impl UniqueGenGen<'_> { + #[allow(clippy::should_implement_trait)] // we don't return Option pub fn next(&mut self) -> Generation { if self.none_yet.next().is_some() { self.gen.increment() } let r = *self.gen; @@ -340,10 +341,11 @@ pub trait ClampTable: Sized+Debug { } impl ClampTable for Coord { - fn clamped(self, range: Coord) -> Result> { - if self < 0 { return Err(PosOffTableError{ clamped: 0, }) } - if self > range { return Err(PosOffTableError{ clamped: range }) } - return Ok(self) + #[throws(PosOffTableError)] + fn clamped(self, range: Coord) -> Coord { + if self < 0 { throw!(PosOffTableError{ clamped: 0, }) } + if self > range { throw!(PosOffTableError{ clamped: range }) } + self } } -- 2.30.2