Skip to content

Commit

Permalink
Remove a couple unnecessary panics
Browse files Browse the repository at this point in the history
By folding them in the Error case of their encompassing Result

Tool-aided by [comby-rust](https://github.com/huitseeker/compby-rust)
  • Loading branch information
huitseeker committed Apr 17, 2021
1 parent 3606c3f commit 5fef8a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion blockchain/message_pool/src/msgpool/test_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl Provider for TestApi {
}

fn messages_for_tipset(&self, h: &Tipset) -> Result<Vec<ChainMessage>, Error> {
let (us, s) = self.messages_for_block(&h.blocks()[0]).unwrap();
let (us, s) = self.messages_for_block(&h.blocks()[0])?;
let mut msgs = Vec::new();

for msg in us {
Expand Down
2 changes: 1 addition & 1 deletion ipld/graphsync/src/libp2p/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Encoder for GraphSyncCodec {
type Item = GraphSyncMessage;

fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> {
let proto_msg = proto::Message::try_from(item).unwrap();
let proto_msg = proto::Message::try_from(item)?;
let buf: Vec<u8> = proto_msg.write_to_bytes()?;

self.length_codec.encode(Bytes::from(buf), dst)
Expand Down

0 comments on commit 5fef8a4

Please sign in to comment.