From aca957a526758843cdb1f836f2ea6cb27282899e Mon Sep 17 00:00:00 2001 From: p3t3rix <5238284+p3t3rix@users.noreply.github.com> Date: Fri, 8 Jul 2022 11:32:19 +0200 Subject: [PATCH] Fix lazy evaluation clippy error (#235) --- rspirv/binary/decoder.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rspirv/binary/decoder.rs b/rspirv/binary/decoder.rs index c225b5b2..3a43868f 100644 --- a/rspirv/binary/decoder.rs +++ b/rspirv/binary/decoder.rs @@ -16,7 +16,7 @@ const WORD_NUM_BYTES: usize = 4; /// surely consume the number of words decoded, while unsuccessful decoding /// may consume any number of bytes. /// -/// TODO: The decoder should not conume words if an error occurs. +/// TODO: The decoder should not consume words if an error occurs. /// /// Different from the [`Parser`](struct.Parser.html), /// this decoder is low-level; it has no knowledge of the SPIR-V grammar. @@ -162,14 +162,10 @@ impl<'a> Decoder<'a> { None => &self.bytes[self.offset..], }; // Find the null terminator. - let first_null_byte = - slice - .iter() - .position(|&c| c == 0) - .ok_or_else(|| match self.limit { - Some(_) => Error::LimitReached(self.offset + slice.len()), - None => Error::StreamExpected(self.offset), - })?; + let first_null_byte = slice.iter().position(|&c| c == 0).ok_or(match self.limit { + Some(_) => Error::LimitReached(self.offset + slice.len()), + None => Error::StreamExpected(self.offset), + })?; // Validate the string is utf8. let result = str::from_utf8(&slice[..first_null_byte]) .map_err(|e| Error::DecodeStringFailed(self.offset, format!("{}", e)))?;