fix: declare unreachable code as such
Those cases previously returned an error, which isn't correct as those
cases cannot be reached, hence should panic if they are reaches.
diff --git a/src/block.rs b/src/block.rs
index 87be3eb..cbb07de 100644
--- a/src/block.rs
+++ b/src/block.rs
@@ -109,9 +109,8 @@
self.node = Some(decoded);
Ok(self.node.as_ref().unwrap())
} else {
- Err(BlockError::DecodeError(
- "Block is missing data.".to_string(),
- ))
+ // All existing contructors make sure that eithe `self.node` or `self.raw` is set.
+ unreachable!()
}
}
@@ -130,7 +129,8 @@
self.raw = Some(encoded);
Ok(self.raw.as_ref().unwrap())
} else {
- Err(BlockError::EncodeError("Block is missing data".to_string()))
+ // All existing contructors make sure that eithe `self.node` or `self.raw` is set.
+ unreachable!()
}
}
@@ -296,9 +296,8 @@
self.node_cached = Some(decoded);
Ok(self.node_cached.as_ref().unwrap())
} else {
- Err(BlockError::DecodeError(
- "Block is missing data.".to_string(),
- ))
+ // All existing contructors make sure that eithe `self.node` or `self.raw` is set.
+ unreachable!()
}
}
@@ -324,7 +323,8 @@
self.raw_cached = Some(encoded);
Ok(self.raw_cached.as_ref().unwrap())
} else {
- Err(BlockError::EncodeError("Block is missing data".to_string()))
+ // All existing contructors make sure that eithe `self.node` or `self.raw` is set.
+ unreachable!()
}
}