Skip to content

Commit 499d0c5

Browse files
committed
apply feedback from Kevin B.
1 parent cacc981 commit 499d0c5

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

src/idiomatic/leveraging-the-type-system/raii.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
minutes: 30
2+
minutes: 60
33
---
44

55
# RAII: `Drop` trait
@@ -57,7 +57,7 @@ fn main() -> Result<(), std::io::Error> {
5757
}
5858
```
5959

60-
- Note that `Drop::drop` cannot return errors. Any fallible logic must be
60+
- Note that `Drop::drop` cannot return a Result. Any fallible logic must be
6161
handled internally or ignored. In the standard library, errors during FD
6262
closure inside `Drop` are silently discarded. See the implementation:
6363
<https://doc.rust-lang.org/src/std/os/fd/owned.rs.html#169-196>

src/idiomatic/leveraging-the-type-system/raii/drop_bomb.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn main() -> io::Result<()> {
4848
in an unfinished state. The destructor panics if the transaction has not been
4949
explicitly finalized (for example, with `commit()`).
5050

51-
- The finalizing operation (such as `commit()`) usually take `self` by value.
51+
- The finalizing operation (such as `commit()`) usually takes `self` by value.
5252
This ensures that once the transaction is finalized, the original object can
5353
no longer be used.
5454

@@ -62,7 +62,7 @@ fn main() -> io::Result<()> {
6262
debug builds. Whether this is appropriate depends on the guarantees your API
6363
must enforce.
6464

65-
- Panicking in Release builds is reasonable when silent misuse would cause major
65+
- Panicking in release builds is reasonable when silent misuse would cause major
6666
correctness or security problems.
6767

6868
## More to explore

src/idiomatic/leveraging-the-type-system/raii/drop_bomb_forget.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ In the previous slide we saw that calling
4242
[`std::mem::forget`](https://doc.rust-lang.org/std/mem/fn.forget.html) prevents
4343
`Drop::drop` from ever running.
4444

45-
Remember that `mem::forget` leaks the value. This is safe in Rust, but the
46-
memory will not be reclaimed.
45+
Remember that `mem::forget` intentionally leaks the value. This is memory-safe
46+
in Rust, but the memory will not be reclaimed.
4747

4848
However, this avoids needing a runtime flag: when the transaction is
4949
successfully committed, we can _defuse_ the drop bomb — meaning we prevent

src/idiomatic/leveraging-the-type-system/raii/drop_guards.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Drop for MutexGuard<'_> {
4444
## More to Explore
4545

4646
This example shows a C++ style mutex that does not contain the data it protects.
47-
While this is non idiomatic in Rust, the goal here is only to illustrate the
47+
While this is non-idiomatic in Rust, the goal here is only to illustrate the
4848
core idea of a drop guard, not to demonstrate a proper Rust mutex design.
4949

5050
For brevity, several features are omitted:
@@ -54,7 +54,7 @@ For brevity, several features are omitted:
5454
mechanism.
5555
- Ergonomic access via `Deref` and `DerefMut` on `MutexGuard` (letting the guard
5656
behave like a `&T` or `&mut T`).
57-
- A fully blocking `.lock()` method and a non blocking `try_lock` variant.
57+
- A fully blocking `.lock()` method and a non-blocking `try_lock` variant.
5858

5959
You can explore the
6060
[`Mutex` implementation in Rust’s std library](https://doc.rust-lang.org/std/sync/struct.Mutex.html)

src/idiomatic/leveraging-the-type-system/raii/drop_skipped.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ fn main() {
5656
- Remove the `mem::forget` call, then uncomment the `panic!` below it. What do
5757
you expect now?
5858

59-
With the default `panic=unwind` setting, the stack still unwinds and
59+
With the default `panic = "unwind"` setting, the stack still unwinds and
6060
destructors run, even when the panic starts in `main`.
6161

6262
- With
63-
[`panic=abort`](https://doc.rust-lang.org/cargo/reference/profiles.html#panic),
63+
[`panic = "abort"`](https://doc.rust-lang.org/cargo/reference/profiles.html#panic),
6464
no unwinding takes place.
6565

6666
- Finally, uncomment the `panic!` inside `Foo::drop` and run it. Ask the class:

src/idiomatic/leveraging-the-type-system/raii/scope_guard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Scope Guards
22

33
A scope guard uses the `Drop` trait to run cleanup code automatically when a
4-
scope exits even during unwinding.
4+
scope exits, even during unwinding.
55

66
```rust,editable,compile_fail
77
use scopeguard::{ScopeGuard, guard};

src/idiomatic/leveraging-the-type-system/typestate-pattern.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
minutes: 30
2+
minutes: 65
33
---
44

55
## Typestate Pattern: Problem

0 commit comments

Comments
 (0)