Trait ghost_cell::ghost_borrow::GhostBorrow
source · [−]pub trait GhostBorrow<'a, 'brand> {
type Result;
fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result;
}
Expand description
A trait for implementing multiple borrows for any number of arguments, using a GhostToken<'a, 'brand>
.
Implemented for a mixture of tuple and array types.
Required Associated Types
Required Methods
sourcefn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result
fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result
Borrows any number of GhostCell
s at the same time.
Example
use ghost_cell::{GhostToken, GhostCell, GhostBorrow};
let value = GhostToken::new(|mut token| {
let cell1 = GhostCell::new(42);
let cell2 = GhostCell::new(47);
let (reference1, reference2): (&i32, &i32) = (&cell1, &cell2).borrow(&token);
(*reference1, *reference2)
});
assert_eq!((42, 47), value);