Skip to content

Commit

Permalink
expect instead of unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Sep 30, 2022
1 parent 52ccc4f commit 5862f78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/fastfield/multivalued/writer.rs
Expand Up @@ -365,7 +365,9 @@ impl MultiValueU128FastFieldWriter {
for field_value in doc.field_values() {
if field_value.field == self.field {
let value = field_value.value();
let ip_addr = value.as_ip().unwrap();
let ip_addr = value
.as_ip()
.expect(&format!("expected and ip, but got {:?}", value));
let value = ip_addr.to_u128();
self.add_val(value);
}
Expand Down
5 changes: 4 additions & 1 deletion src/fastfield/writer.rs
Expand Up @@ -329,7 +329,10 @@ impl U128FastFieldWriter {
pub fn add_document(&mut self, doc: &Document) {
match doc.get_first(self.field) {
Some(v) => {
let ip_addr = v.as_ip().unwrap();
let ip_addr = v
.as_ip()
.expect(&format!("expected and ip, but got {:?}", v));

let value = ip_addr.to_u128();
self.add_val(value);
}
Expand Down

0 comments on commit 5862f78

Please sign in to comment.