From e16769c9b16223c491766f9c9b2c828ee2253ed4 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Sat, 16 Nov 2019 11:14:10 +0100 Subject: less unwraps --- src/ffi.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/ffi.rs') diff --git a/src/ffi.rs b/src/ffi.rs index 285aeba..5c276d8 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -6,7 +6,7 @@ use libc::{c_char, c_double, c_int, c_uint, c_ulong, c_void, time_t}; use error::{Error, Result}; use std::{error, fmt, str}; - +use std::borrow::Cow; use utils::ToStr; notmuch_enum! { @@ -57,6 +57,14 @@ impl ToStr for Status { fn to_str<'a>(&self) -> std::result::Result<&'a str, str::Utf8Error> { unsafe { notmuch_status_to_string((*self).into()) }.to_str() } + + fn to_str_unchecked<'a>(&self) -> &'a str { + unsafe { notmuch_status_to_string((*self).into()) }.to_str_unchecked() + } + + fn to_string_lossy<'a>(&self) -> Cow<'a, str> { + unsafe { notmuch_status_to_string((*self).into()) }.to_string_lossy() + } } impl fmt::Display for Status { -- cgit v1.2.1