Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some clippy errors #235

Merged
merged 4 commits into from
Jul 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions rspirv/binary/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)))?;
Expand Down