Summary
Introduce non-panicking borrow methods on RefCell<T>.
Motivation
Whenever something is built from user input, for example a graph in which nodes
are RefCell<T> values, it is primordial to avoid panicking on bad input. The
only way to avoid panics on cyclic input in this case is a way to
conditionally-borrow the cell contents.
Detailed design
/// Returned when `RefCell::try_borrow` fails.
/// Returned when `RefCell::try_borrow_mut` fails.
Drawbacks
This departs from the fallible/infallible convention where we avoid providing both panicking and non-panicking methods for the same operation.
Alternatives
The alternative is to provide a borrow_state method returning the state
of the borrow flag of the cell, i.e:
See the Rust tracking issue for this feature.
Unresolved questions
There are no unresolved questions.