From: Ian Jackson Date: Thu, 31 Mar 2022 00:34:27 +0000 (+0100) Subject: clippy: Miscellaneous minor changes X-Git-Tag: otter-1.0.0~48 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=70f3a6adb5c817c4505ce3e97374f30adecbf52d;p=otter.git clippy: Miscellaneous minor changes Signed-off-by: Ian Jackson --- 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 } }