diff options
| author | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-12-18 07:41:02 +0100 |
|---|---|---|
| committer | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-12-18 07:41:02 +0100 |
| commit | 2baa9d13ad4c5c2c6e55b6ca49c92a4d2434fba7 (patch) | |
| tree | af5cdafc2124f65aded2f7ec337c3e30706e5995 | |
| parent | e5a7acf1a0ced9b9d5ccfef79c46579f359fac94 (diff) | |
| download | mail-2baa9d13ad4c5c2c6e55b6ca49c92a4d2434fba7.tar.gz | |
do not require a mutable reference for getting message replies
| -rw-r--r-- | src/message.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/message.rs b/src/message.rs index bf46a4e..b2b466f 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,5 +1,6 @@ use std::ffi::CString; use std::path::PathBuf; +use std::cell::RefCell; use supercow::{Supercow}; use error::{Error, Result}; @@ -24,7 +25,7 @@ where O: MessageOwner + 'o, { pub(crate) handle: MessagePtr, - marker: ScopedPhantomcow<'o, O>, + marker: RefCell<ScopedPhantomcow<'o, O>>, } impl<'o, O> MessageOwner for Message<'o, O> where O: MessageOwner + 'o {} @@ -41,7 +42,7 @@ where { Message { handle: MessagePtr { ptr }, - marker: owner.into(), + marker: RefCell::new(owner.into()), } } @@ -55,10 +56,11 @@ where tid.to_str().unwrap().to_string() } - pub fn replies(self: &mut Self) -> Messages<'o, O> { + pub fn replies(self: &Self) -> Messages<'o, O> { Messages::<'o, O>::from_ptr( unsafe { ffi::notmuch_message_get_replies(self.handle.ptr) }, - ScopedPhantomcow::<'o, O>::share(&mut self.marker) + // will never panic since the borrow is released immediately + ScopedPhantomcow::<'o, O>::share(&mut *(self.marker.borrow_mut())) ) } |
