diff options
| author | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2019-11-16 11:14:10 +0100 |
|---|---|---|
| committer | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2019-11-16 11:14:10 +0100 |
| commit | e16769c9b16223c491766f9c9b2c828ee2253ed4 (patch) | |
| tree | d1a6e68acc5bbb14d9f1e6bf65d7549916ff95b9 /src/thread.rs | |
| parent | 084675fdfe1329cbd58a48f2306b7c61dec08834 (diff) | |
| download | mail-e16769c9b16223c491766f9c9b2c828ee2253ed4.tar.gz | |
less unwraps
Diffstat (limited to 'src/thread.rs')
| -rw-r--r-- | src/thread.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/thread.rs b/src/thread.rs index 1ebcc24..ffc1f2f 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -1,4 +1,5 @@ use std::ops::Drop; +use std::borrow::Cow; use ffi; use utils::{ToStr, ScopedSupercow, ScopedPhantomcow}; @@ -43,9 +44,9 @@ where } } - pub fn id(self: &Self) -> String { + pub fn id(self: &Self) -> &str { let tid = unsafe { ffi::notmuch_thread_get_thread_id(self.ptr) }; - tid.to_str().unwrap().to_string() + tid.to_str().unwrap() } pub fn total_messages(self: &Self) -> i32 { @@ -75,18 +76,16 @@ where <Self as ThreadExt<'d, 'q>>::tags(self) } - pub fn subject(self: &Self) -> String { + pub fn subject(self: &Self) -> Cow<'_, str> { let sub = unsafe { ffi::notmuch_thread_get_subject(self.ptr) }; - - sub.to_str().unwrap().to_string() + sub.to_string_lossy() } pub fn authors(self: &Self) -> Vec<String> { let athrs = unsafe { ffi::notmuch_thread_get_authors(self.ptr) }; athrs - .to_str() - .unwrap() + .to_string_lossy() .split(',') .map(|s| s.to_string()) .collect() |
