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 eb00ef6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 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
2 changes: 1 addition & 1 deletion src/schema/field_type.rs
Expand Up @@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
use thiserror::Error;

use super::Cardinality;
use super::ip_options::IpOptions;
use super::Cardinality;
use crate::schema::bytes_options::BytesOptions;
use crate::schema::facet_options::FacetOptions;
use crate::schema::{
Expand Down

0 comments on commit eb00ef6

Please sign in to comment.