Skip to content

Commit eb00ef6

Browse files
committed
expect instead of unwrap
1 parent 52ccc4f commit eb00ef6

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/fastfield/multivalued/writer.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ impl MultiValueU128FastFieldWriter {
365365
for field_value in doc.field_values() {
366366
if field_value.field == self.field {
367367
let value = field_value.value();
368-
let ip_addr = value.as_ip().unwrap();
368+
let ip_addr = value
369+
.as_ip()
370+
.expect(&format!("expected and ip, but got {:?}", value));
369371
let value = ip_addr.to_u128();
370372
self.add_val(value);
371373
}

src/fastfield/writer.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@ impl U128FastFieldWriter {
329329
pub fn add_document(&mut self, doc: &Document) {
330330
match doc.get_first(self.field) {
331331
Some(v) => {
332-
let ip_addr = v.as_ip().unwrap();
332+
let ip_addr = v
333+
.as_ip()
334+
.expect(&format!("expected and ip, but got {:?}", v));
335+
333336
let value = ip_addr.to_u128();
334337
self.add_val(value);
335338
}

src/schema/field_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
55
use serde_json::Value as JsonValue;
66
use thiserror::Error;
77

8-
use super::Cardinality;
98
use super::ip_options::IpOptions;
9+
use super::Cardinality;
1010
use crate::schema::bytes_options::BytesOptions;
1111
use crate::schema::facet_options::FacetOptions;
1212
use crate::schema::{

0 commit comments

Comments
 (0)