adambard / adambard/learnxinyminutes-docs
[en/rust] Emphasize the difference between &str and String.
- 主要语言
- Markdown
- 星标
- 12.3k
- 派生
- 3.7k
- 平均合并
- 13 小时 10 分钟
- 30 天内合并 PR
- 6
描述
The difference between a heap allocated `String` and a Slice `&str` is not emphasized properly.
As already mentioned a `String` is a heap allocated String. In addition it should be clearly emphasized, that a `String` is a vector of bytes and always holds a valid UTF-8 sequence. Its growable and does not hold a null termination character!
When it comes to `&str` I miss a comment about the fact, that slices are allocates in read-only-memory. The association between a heap allocated string and a slice needs to be explained in detail:
A slice is a `&[u8]` and points to a valid UTF-8 sequence, and can be used to view into a String. A `&[T] ` is a view into `Vec`.
Especially for a Rust-beginner these side notes can be very useful for a deeper understanding.
贡献指南
调研方向
Start by opening the en/rust document and reading its existing String and &str sections. Revise the explanation to clearly distinguish ownership, UTF-8 validity, growth, termination, and the relationship between strings, byte slices, and vectors; it is done when these beginner-focused differences are accurate and explicit.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100