Skip to content

Commit 04504ab

Browse files
authored
Merge pull request #79 from wiktor-k/wiktor/disallow-unwraps
Propagate error if retrieving encoded length fails instead of panic
2 parents fe210c2 + 4986d0b commit 04504ab

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/codec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ where
7575
fn encode(&mut self, item: Output, dst: &mut BytesMut) -> Result<(), Self::Error> {
7676
let mut bytes = Vec::new();
7777

78-
let len = item.encoded_len().unwrap() as u32;
78+
let len = item.encoded_len().map_err(ProtoError::SshEncoding)? as u32;
7979
len.encode(&mut bytes).map_err(ProtoError::SshEncoding)?;
8080

8181
item.encode(&mut bytes).map_err(ProtoError::SshEncoding)?;

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![deny(missing_debug_implementations)]
33
#![deny(unsafe_code)]
44
#![deny(missing_docs)]
5+
#![deny(clippy::unwrap_used)]
56

67
pub mod proto;
78

0 commit comments

Comments
 (0)