Skip to content

Commit b34bb93

Browse files
committed
Add some further edits to #2433
1 parent 14e2174 commit b34bb93

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/ch19-01-unsafe-rust.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,11 @@ that data accessed from different threads is done safely.
408408

409409
### Implementing an Unsafe Trait
410410

411-
Another use-case for `unsafe` is implementing an unsafe trait.
412-
A trait is unsafe when at least one of its methods has some invariant that the
413-
compiler can’t verify. We can declare that a trait is `unsafe` by adding the
414-
`unsafe` keyword before `trait` and marking the implementation of the trait as
415-
`unsafe` too, as shown in Listing 19-11.
411+
Another use case for `unsafe` is implementing an unsafe trait. A trait is
412+
unsafe when at least one of its methods has some invariant that the compiler
413+
can’t verify. We can declare that a trait is `unsafe` by adding the `unsafe`
414+
keyword before `trait` and marking the implementation of the trait as `unsafe`
415+
too, as shown in Listing 19-11.
416416

417417
```rust,unsafe
418418
{{#rustdoc_include ../listings/ch19-advanced-features/listing-19-11/src/main.rs}}
@@ -437,12 +437,12 @@ those checks manually and indicate as such with `unsafe`.
437437

438438
### Accessing Fields of a Union
439439

440-
The final action that works only with `unsafe` is accessing fields of a `union`
441-
which is similar to a `struct`, but with only one declared field being used
442-
in a particular instance at one time. Unions are primarily used to interface with
443-
unions in C code. Accessing union fields is unsafe because Rust can’t guarantee
444-
the type of the data currently being stored in the union instance. You can
445-
learn more about unions in [the reference][reference].
440+
The final action that works only with `unsafe` is accessing fields of a
441+
*union*. A `union` is similar to a `struct`, but only one declared field is
442+
used in a particular instance at one time. Unions are primarily used to
443+
interface with unions in C code. Accessing union fields is unsafe because Rust
444+
can’t guarantee the type of the data currently being stored in the union
445+
instance. You can learn more about unions in [the reference][reference].
446446

447447
### When to Use Unsafe Code
448448

@@ -458,6 +458,5 @@ ch04-02-references-and-borrowing.html#dangling-references
458458
ch03-01-variables-and-mutability.html#differences-between-variables-and-constants
459459
[extensible-concurrency-with-the-sync-and-send-traits]:
460460
ch16-04-extensible-concurrency-sync-and-send.html#extensible-concurrency-with-the-sync-and-send-traits
461-
462461
[the-slice-type]: ch04-03-slices.html#the-slice-type
463462
[reference]: ../reference/items/unions.html

0 commit comments

Comments
 (0)