Also worth mentioning is that it's almost always better to use Cell instead of RefCell for Copy types (like i32). This avoids the overhead of the runtime borrow check and can never cause a panic.
Arc, Rc, Box and Cell/RefCell are the most confusing aspects, so far, of my learning Rust. I will have to re-watch your videos a few times, in hopes of grasping these concepts. Thanks!
Unsafe Rust gives you a few "superpowers", but playing jedi mind tricks with the borrow checker is not one of them. The borrow checker will still check your code. :D As far as I remember these types with internal mutability all ultimately use UnsafeCell as a building block. The compiler gives UnsafeCell some special treatment.
So why would RefCell be unsafe if it's implemented by the Rust devs? The entire compiler could have bugs that make Rust code fail, so why not give RefCell the same guarantee and call it a safe intrinsic?
because it just checking if it's sending correct message or not in the real world example it will not take mutable reference of a string because we just want send that message via email or number , so we are not storing it and we can't really change our implementation just for test