Skip to content

Commit 9f5f979

Browse files
committed
fix some clippy warnings
1 parent 0a95c8f commit 9f5f979

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

capnp/src/serialize.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,7 @@ where
339339

340340
let segment_count = u32::from_le_bytes(buf[0..4].try_into().unwrap()).wrapping_add(1) as usize;
341341

342-
if segment_count >= SEGMENTS_COUNT_LIMIT {
343-
return Err(Error::from_kind(ErrorKind::InvalidNumberOfSegments(
344-
segment_count,
345-
)));
346-
} else if segment_count == 0 {
342+
if segment_count >= SEGMENTS_COUNT_LIMIT || segment_count == 0 {
347343
return Err(Error::from_kind(ErrorKind::InvalidNumberOfSegments(
348344
segment_count,
349345
)));

capnp/src/text.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ impl<'a> Builder<'a> {
174174
}
175175

176176
pub fn as_bytes(self) -> &'a [u8] {
177-
&self.bytes[..]
177+
self.bytes
178178
}
179179

180180
/// Converts to a `str`, returning a error if the data contains invalid utf-8.
181181
pub fn to_str(self) -> core::result::Result<&'a str, core::str::Utf8Error> {
182-
str::from_utf8(&self.bytes[..])
182+
str::from_utf8(self.bytes)
183183
}
184184

185185
#[cfg(feature = "alloc")]

0 commit comments

Comments
 (0)