Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actualize ch19-01 for current unsafe actions #2433

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/ch19-01-unsafe-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ that data accessed from different threads is done safely.

### Implementing an Unsafe Trait

The final action that works only with `unsafe` is implementing an unsafe trait.
Another use-case for `unsafe` is implementing an unsafe trait.
A trait is unsafe when at least one of its methods has some invariant that the
compiler can’t verify. We can declare that a trait is `unsafe` by adding the
`unsafe` keyword before `trait` and marking the implementation of the trait as
Expand Down Expand Up @@ -437,8 +437,9 @@ those checks manually and indicate as such with `unsafe`.

### Accessing Fields of a Union

A `union` is similar to a `struct`, but only one declared field is used in a
particular instance at one time. Unions are primarily used to interface with
The final action that works only with `unsafe` is accessing fields of a `union`
which is similar to a `struct`, but with only one declared field being used
in a particular instance at one time. Unions are primarily used to interface with
unions in C code. Accessing union fields is unsafe because Rust can’t guarantee
the type of the data currently being stored in the union instance. You can
learn more about unions in [the reference][reference].
Expand All @@ -457,5 +458,6 @@ ch04-02-references-and-borrowing.html#dangling-references
ch03-01-variables-and-mutability.html#differences-between-variables-and-constants
[extensible-concurrency-with-the-sync-and-send-traits]:
ch16-04-extensible-concurrency-sync-and-send.html#extensible-concurrency-with-the-sync-and-send-traits

[the-slice-type]: ch04-03-slices.html#the-slice-type
[reference]: ../reference/items/unions.html