Struct interior_mutability_pointer::Imp [−][src]
pub struct Imp<T> { /* fields omitted */ }Expand description
A wrapper around Rc<RefCell<T>> allowing immediate access to inner methods,
without the need for .borrow() or .borrow_mut(),
allowing for a more seamless pointer experience.
let mut k = Imp::new(String::new());
let p = k.clone(); // Clone the pointer.
k.push_str("yo");
println!("{} {}", k, p); // Prints "yo yo"Also allows the use of operators:
let mut k = Imp::new(5);
let p = k.clone(); // Clone the pointer.
k += 5;
println!("{} {}", k, p); // Prints "10 10"The biggest difference to Rc<RefCell<T>> is that your pointer instance will need to be marked as mut
if you want to use &mut self methods, as opposed to Rc<RefCell<T>> instances where you can call .borrow_mut(),
removing the need for the mut keyword.
However, this does not mean that all clones of the pointer need to be mutable!
let k = Imp::new(String::new());
let mut p = k.clone(); // Clone the pointer.
p.push_str("yo");
println!("{:?} {:?}", k, p); // Prints "yo yo"Implementations
Trait Implementations
Performs the += operation. Read more
Performs the += operation. Read more
Performs the &= operation. Read more
Performs the &= operation. Read more
Performs the |= operation. Read more
Performs the |= operation. Read more
Performs the ^= operation. Read more
Performs the ^= operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Performs the %= operation. Read more
Performs the %= operation. Read more
Performs the <<= operation. Read more
Performs the <<= operation. Read more
Performs the >>= operation. Read more
Performs the >>= operation. Read more
Performs the -= operation. Read more
Performs the -= operation. Read more
Auto Trait Implementations
impl<T> !RefUnwindSafe for Imp<T>
impl<T> !UnwindSafe for Imp<T>
Blanket Implementations
Mutably borrows from an owned value. Read more