You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: reference/src/glossary.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ If data immediately pointed to by a `*const T` or `&*const T` is mutated, that's
14
14
*Interior mutability* refers to the ability to perform interior mutation without causing UB.
15
15
All interior mutation in Rust has to happen inside an [`UnsafeCell`](https://doc.rust-lang.org/core/cell/struct.UnsafeCell.html), so all data structures that have interior mutability must (directly or indirectly) use `UnsafeCell` for this purpose.
16
16
17
-
#### Validity and safety invariant
17
+
#### Validity Invariant
18
18
19
19
The *validity invariant* is an invariant that all data must uphold any time it is accessed or copied in a typed manner.
20
20
This invariant is known to the compiler and exploited by optimizations such as improved enum layout or eliding in-bounds checks.
@@ -31,6 +31,8 @@ fn main() { unsafe {
31
31
} }
32
32
```
33
33
34
+
#### Safety Invariant
35
+
34
36
The *safety* invariant is an invariant that safe code may assume all data to uphold.
35
37
This invariant is used to justify which operations safe code can perform.
36
38
The safety invariant can be temporarily violated by unsafe code, but must always be upheld when interfacing with unknown safe code.
0 commit comments