File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
src/librustc_data_structures Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1- //! An immutable, owned value.
1+ //! An immutable, owned value (except for interior mutability) .
22//!
33//! The purpose of `Frozen` is to make a value immutable for the sake of defensive programming. For example,
44//! suppose we have the following:
3737//! `Frozen` impls `Deref`, so we can ergonomically call methods on `Bar`, but it doesn't `impl
3838//! DerefMut`. Now calling `foo.compute.mutate()` will result in a compile-time error stating that
3939//! `mutate` requires a mutable reference but we don't have one.
40+ //!
41+ //! # Caveats
42+ //!
43+ //! - `Frozen` doesn't try to defend against interior mutability (e.g. `Frozen<RefCell<Bar>>`).
44+ //! - `Frozen` doesn't pin it's contents (e.g. one could still do `foo.computed =
45+ //! Frozen::freeze(new_bar)`).
4046
4147/// An owned immutable value.
4248#[ derive( Debug ) ]
You can’t perform that action at this time.
0 commit comments