expect instead of unwrap

This commit is contained in:
Pascal Seitz
2022-09-30 11:01:12 +08:00
parent f5039f1846
commit 787a37bacf
3 changed files with 8 additions and 3 deletions

View File

@@ -317,7 +317,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);
}

View File

@@ -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);
}

View File

@@ -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::{