Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=be4dfa9fda3dbe2c8ccb42c3785bd658
This code panics and I do not think it should.
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Clone, Copy)]
struct Item(u32);
#[derive(Clone)]
struct Interp(Rc<RefCell<Item>>);
fn func(interp: &Interp, item: u32) {
interp.0.borrow_mut();
println!("{}", item);
}
fn main() {
let interp = Interp(Rc::new(RefCell::new(Item(42))));
func(&interp.clone(), interp.0.borrow().0);
}
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=be4dfa9fda3dbe2c8ccb42c3785bd658
This code panics and I do not think it should.