@@ -24,19 +24,19 @@ maintains the contracts the trait requires.
24
24
25
25
You can use ` unsafe ` on a block to declare that all unsafe actions performed
26
26
within are verified to uphold the contracts of those operations. For instance,
27
- the index passed to ` slice::get_unchecked ` is in-bounds.
27
+ the index passed to [ ` slice::get_unchecked ` ] [ get_unchecked ] is in-bounds.
28
28
29
29
You can use ` unsafe ` on a trait implementation to declare that the implementation
30
- upholds the trait's contract. For instance, that a type implementing ` Send ` is
30
+ upholds the trait's contract. For instance, that a type implementing [ ` Send ` ] is
31
31
really safe to move to another thread.
32
32
33
33
The standard library has a number of unsafe functions, including:
34
34
35
- * ` slice::get_unchecked ` , which performs unchecked indexing, allowing
36
- memory safety to be freely violated.
37
- * ` mem::transmute ` reinterprets some value as having a given type, bypassing
38
- type safety in arbitrary ways (see [ conversions] for details).
39
- * Every raw pointer to a sized type has an ` offset ` method that
35
+ * [ ` slice::get_unchecked ` ] [ get_unchecked ] , which performs unchecked indexing,
36
+ allowing memory safety to be freely violated.
37
+ * [ ` mem::transmute ` ] [ transmute ] reinterprets some value as having a given type,
38
+ bypassing type safety in arbitrary ways (see [ conversions] for details).
39
+ * Every raw pointer to a sized type has an [ ` offset ` ] [ ptr_offset ] method that
40
40
invokes Undefined Behavior if the passed offset is not [ "in bounds"] [ ptr_offset ] .
41
41
* All FFI (Foreign Function Interface) functions are ` unsafe ` to call because the
42
42
other language can do arbitrary operations that the Rust compiler can't check.
@@ -65,11 +65,11 @@ relationship between Safe and Unsafe Rust. Safe Rust inherently has to
65
65
trust that any Unsafe Rust it touches has been written correctly.
66
66
On the other hand, Unsafe Rust has to be very careful about trusting Safe Rust.
67
67
68
- As an example, Rust has the ` PartialOrd ` and ` Ord ` traits to differentiate
68
+ As an example, Rust has the [ ` PartialOrd ` ] and [ ` Ord ` ] traits to differentiate
69
69
between types which can "just" be compared, and those that provide a "total"
70
70
ordering (which basically means that comparison behaves reasonably).
71
71
72
- ` BTreeMap ` doesn't really make sense for partially-ordered types, and so it
72
+ [ ` BTreeMap ` ] doesn't really make sense for partially-ordered types, and so it
73
73
requires that its keys implement ` Ord ` . However, ` BTreeMap ` has Unsafe Rust code
74
74
inside of its implementation. Because it would be unacceptable for a sloppy ` Ord `
75
75
implementation (which is Safe to write) to cause Undefined Behavior, the Unsafe
@@ -156,4 +156,8 @@ of the sort of care that must be taken, and what contracts Unsafe Rust must upho
156
156
[ `GlobalAlloc` ] : ../std/alloc/trait.GlobalAlloc.html
157
157
[ conversions ] : conversions.html
158
158
[ ptr_offset ] : ../std/primitive.pointer.html#method.offset
159
-
159
+ [ get_unchecked ] : ../std/primitive.slice.html#method.get_unchecked
160
+ [ transmute ] : ../std/mem/fn.transmute.html
161
+ [ `PartialOrd` ] : ../std/cmp/trait.PartialOrd.html
162
+ [ `Ord` ] : ../std/cmp/trait.Ord.html
163
+ [ `BTreeMap` ] : ../std/collections/struct.BTreeMap.html
0 commit comments