google / google/comprehensive-rust
`static` item example being an `&str` is confusing
- Dominant language
- Rust
- Stars
- 33.4k
- Forks
- 2.1k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 10
Description
The slide on `static`s gives this example:
```rust
static BANNER: &str = "Welcome to RustOS 3.14";
```
Then it describes how the item has a stable address. While this is true, it's confusing because the visible part of the value (the string data) is not actually stored in the static, and the string data itself has a fixed address not due to being part of a static but merely because that's how string literals work.
It would be a bit clearer if we used a type with no indirections such as `u32` or `[u8; N]` so that there aren't multiple layers of pointers involved. Perhaps something like:
```rust
static BANNER: [u8; 22] = *b"Welcome to RustOS 3.14";
```
Contributor guide
Assessment
This issue has not been assessed yet.