Skip to content

Commit

Permalink
[#2] Handle NulError in NormalizeOptions.expand
Browse files Browse the repository at this point in the history
  • Loading branch information
kodemartin committed Jul 14, 2021
1 parent b1b2e5c commit b7f9a7f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<NormalizedAddress, NulError> {
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))
}
}

Expand Down

0 comments on commit b7f9a7f

Please sign in to comment.