Safety
The DerefMut
implementation is unsound due to this library essentially working around the runtime safety provided
by using RefCell
. See Issue #2.
Due to this Imp::new(..)
has been marked as unsafe
.
Interior Mutability Pointer
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 = new;
let p = k.clone; // Clone the pointer.
k.push_str;
println!; // Prints "yo yo"
Also allows the use of operators:
let mut k = new;
let p = k.clone; // Clone the pointer.
k += 5;
println!; // 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 = new;
let mut p = k.clone; // Clone the pointer.
p.push_str;
println!; // Prints "yo yo"
Also supports dynamic dispatch for all your trait ojects, in both mutable and inmutable contexts!
let s = Sheep ;
let d = Dog ;
let mut rc_refcell: =
vec!;
let mut imp: = vec!;
rc_refcell.iter_mut.for_each;
imp.iter_mut.for_each;
let rc_refcell = rc_refcell
.iter
.map
.;
let imp = imp.iter.map.;
println!; // Prints [20, 30]
println!; // Prints [20, 30]