Skip to content

Conversation

@aturon
Copy link
Contributor

@aturon aturon commented Jul 24, 2014

The unwrap method for RefCell was using debug_assert! to check
that the RefCell was not aleady borrowed before unwrapping. However,
disabling this assertion can lead to safety violations.

This commit changes the code to fail explicitly with a useful message,
similarly to the borrow and borrow_mut methods.

The `unwrap` method for `RefCell` was using `debug_assert!` to check
that the `RefCell` was not aleady borrowed before unwrapping. However,
disabling this assertion can lead to safety violations.

This commit changes the code to fail explicitly with a useful message,
similarly to the `borrow` and `borrow_mut` methods.
@aturon aturon closed this Jul 24, 2014
@aturon
Copy link
Contributor Author

aturon commented Jul 24, 2014

Note: this is not actually a problem, because unwrap takes self by value, which precludes any outstanding references. So debug_assert is exactly the right choice.

flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant