aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread.rs
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2019-11-16 11:14:10 +0100
committerDirk Van Haerenborgh <vhdirk@gmail.com>2019-11-16 11:14:10 +0100
commite16769c9b16223c491766f9c9b2c828ee2253ed4 (patch)
treed1a6e68acc5bbb14d9f1e6bf65d7549916ff95b9 /src/thread.rs
parent084675fdfe1329cbd58a48f2306b7c61dec08834 (diff)
downloadmail-e16769c9b16223c491766f9c9b2c828ee2253ed4.tar.gz
less unwraps
Diffstat (limited to 'src/thread.rs')
-rw-r--r--src/thread.rs13
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()