1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-14 14:46:43 +02:00

Add links to std and docs.rs (#2403)

- **Link to relevant crate APIs**
- **Add missing std links**
This commit is contained in:
Martin Geisler 2024-10-15 08:12:25 +02:00 committed by GitHub
parent 25a2fa6a09
commit cf7359fac8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 7 deletions

View File

@ -1,10 +1,14 @@
# Volatile memory access for MMIO # Volatile memory access for MMIO
- Use `pointer::read_volatile` and `pointer::write_volatile`. - Use [`pointer::read_volatile`] and [`pointer::write_volatile`].
- Never hold a reference. - Never hold a reference.
- `addr_of!` lets you get fields of structs without creating an intermediate - Use [`addr_of!`] to get fields of structs without creating an intermediate
reference. reference.
[`pointer::read_volatile`]: https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.read_volatile
[`pointer::write_volatile`]: https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.write_volatile
[`addr_of!`]: https://doc.rust-lang.org/stable/core/ptr/macro.addr_of.html
<details> <details>
- Volatile access: read or write operations may have side-effects, so prevent - Volatile access: read or write operations may have side-effects, so prevent

View File

@ -4,13 +4,16 @@ minutes: 5
# `anyhow` # `anyhow`
The [`anyhow`](https://docs.rs/anyhow/) crate provides a rich error type with The [`anyhow`] crate provides a rich error type with support for carrying
support for carrying additional contextual information, which can be used to additional contextual information, which can be used to provide a semantic trace
provide a semantic trace of what the program was doing leading up to the error. of what the program was doing leading up to the error.
This can be combined with the convenience macros from `thiserror` to avoid This can be combined with the convenience macros from [`thiserror`] to avoid
writing out trait impls explicitly for custom error types. writing out trait impls explicitly for custom error types.
[`anyhow`]: https://docs.rs/anyhow/
[`thiserror`]: https://docs.rs/thiserror/
```rust,editable,compile_fail ```rust,editable,compile_fail
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use std::fs; use std::fs;

View File

@ -7,7 +7,10 @@ minutes: 30
The following implements a very simple parser for an expression language. The following implements a very simple parser for an expression language.
However, it handles errors by panicking. Rewrite it to instead use idiomatic However, it handles errors by panicking. Rewrite it to instead use idiomatic
error handling and propagate errors to a return from `main`. Feel free to use error handling and propagate errors to a return from `main`. Feel free to use
`thiserror` and `anyhow`. [`thiserror`] and [`anyhow`].
[`thiserror`]: https://docs.rs/thiserror
[`anyhow`]: https://docs.rs/anyhow
HINT: start by fixing error handling in the `parse` function. Once that is HINT: start by fixing error handling in the `parse` function. Once that is
working correctly, update `Tokenizer` to implement working correctly, update `Tokenizer` to implement