@@ -51,15 +51,16 @@ parsing all take energy and time.
51
51
rely on its symbols, including ` random ` , being available to our program.
52
52
- _ What is the "safe" keyword?_ \
53
53
It allows callers to call the function without needing to wrap that call in
54
- ` unsafe ` . The [ ` safe ` function qualifier] was introduced in the 2024 edition
55
- of Rust and can only be used within ` extern ` blocks. It was introduced because
56
- ` unsafe ` became a mandatory qualifier for ` extern ` blocks in that edition.
54
+ ` unsafe ` . The [ ` safe ` function qualifier] [ safe ] was introduced in the 2024
55
+ edition of Rust and can only be used within ` extern ` blocks. It was introduced
56
+ because ` unsafe ` became a mandatory qualifier for ` extern ` blocks in that
57
+ edition.
57
58
- _ What is the [ ` std::ffi::c_long ` ] type?_ \
58
59
According to the C standard, an integer that's at least 32 bits wide. On
59
60
today's systems, It's an ` i32 ` on Windows and an ` i64 ` on Linux.
60
61
61
- [ `safe` keyword ] : https://doc.rust-lang.org/reference/safe-keyword.html
62
62
[ `std::ffi::c_long` ] : https://doc.rust-lang.org/std/ffi/type.c_long.html
63
+ [ safe ] : https://doc.rust-lang.org/stable/edition-guide/rust-2024/unsafe-extern.html
63
64
64
65
## Consideration: type safety
65
66
@@ -203,15 +204,12 @@ fn main() {
203
204
}
204
205
```
205
206
206
- > Aside: Lifetimes in the ` format_timestamp() ` function
207
+ > _ Aside: _ Lifetimes in the ` format_timestamp() ` function
207
208
>
208
- > Neither ` 'a ` , nor ` 'static ` correctly describe the lifetime of the string
209
+ > Neither ` 'a ` , nor ` 'static ` , correctly describe the lifetime of the string
209
210
> that's returned. Rust treats it as an immutable reference, but subsequent
210
211
> calls to ` ctime ` will overwrite the static buffer that the string occupies.
211
212
212
- Bonus points: can anyone spot the lifetime bug? ` format_timestamp() ` should
213
- return a ` &'static str ` .
214
-
215
213
## Consideration: Representation mismatch
216
214
217
215
Different programming languages have made different design decisions and this
0 commit comments