From 2baa9d13ad4c5c2c6e55b6ca49c92a4d2434fba7 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Tue, 18 Dec 2018 07:41:02 +0100 Subject: do not require a mutable reference for getting message replies --- src/message.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') 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>, } 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())) ) } -- cgit v1.2.1