Uh oh!
There was an error while loading. Please reload this page.
Show impl for RefCell, Ref & RefMut - #14811
Conversation
alexcrichton
commented
Jun 11, 2014
This is an interesting direction to take because it means that |
forticulous
commented
Jun 11, 2014
I was trying to stick to the idea that the |
huonw
commented
Jun 11, 2014
let x = RefCell::new(1);let y = x.borrow_mut();// this will fail, due to the `y` mutable borrow stopping// any other borrow/borrow_mut.println!("{}", x); |
forticulous
commented
Jun 11, 2014
This would also fail for the same reasons: letmut x = 75u;let y = &mut x;println!("{}", x); |
alexcrichton
commented
Jun 11, 2014
Your example code, @forticulous, does not fail (you can try to run it). @huonw explained why this type is fallible. |
forticulous
commented
Jun 11, 2014
I did just run it on rust-lang.org |
alexcrichton
commented
Jun 11, 2014
Note that it is a compilation error, not a runtime error. |
huonw
commented
Jun 11, 2014
The RefCell version fails at runtime. The type is design as a way to get around the hard limits of |
forticulous
commented
Jun 11, 2014
That's the whole idea of |
forticulous
commented
Jun 11, 2014
Here's maybe a better example (though this would also be my fault) letmut x = Rc::new(75u);let y = x.make_unique();println!("{}", x);
error: cannot borrow `x` asimmutable because it is also borrowed asmutable |
huonw
commented
Jun 11, 2014
Yep, that's the idea of I would be very happy to merge |
forticulous
commented
Jun 11, 2014
Yeah, it seems like when you choose to use I can cut out the |
forticulous
commented
Jun 11, 2014
Updated with just |
feat: Render hover actions for closure captures and sig Also special cases closures for ranged type hover to render the closure hover instead
Clippy should not lint 2 blocks expression for comparison_chain. Fixesrust-lang/rust-clippy#4725 changelog: [`comparison_chain`]: do not lint 2 blocks expression
Show impl for RefCell and friends