From b7f9a7f00098a2503d7cda44c6852034e1b50155 Mon Sep 17 00:00:00 2001 From: Konstantinos Demartinos Date: Wed, 14 Jul 2021 08:03:08 +0300 Subject: [PATCH] [#2] Handle NulError in NormalizeOptions.expand --- src/expand.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/expand.rs b/src/expand.rs index b3c84bc..7f76079 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -23,7 +23,7 @@ #![allow(unused)] use bitflags::bitflags; -use std::ffi::{CStr, CString}; +use std::ffi::{CStr, CString, NulError}; use std::iter::Iterator; use libc::{c_char, size_t}; @@ -319,10 +319,10 @@ impl<'a> NormalizeOptions<'a> { } /// Expand address. - pub fn expand(&mut self, address: &str) -> NormalizedAddress { + pub fn expand(&mut self, address: &str) -> Result { let mut options = self.libpostal_options(); - let c_address = CString::new(address).unwrap(); - options.expand(&c_address) + let c_address = CString::new(address)?; + Ok(options.expand(&c_address)) } }