vulns.co
/
GKData.io MCP

The Rust Project · 1 min read

Rust Slices: Bounds, Borrowing, and Text Boundaries

The Rust Book uses text processing to show why a borrowed slice stays tied to its source buffer while an integer position can become detached from the data it describes. The language reference explains that safe slice access checks bounds. The strings chapter separately explains why byte positions must respect UTF-8 character boundaries.

Open the reference Implementation GuideReviewed 2026-10-12

How to use this reference

Keep a parser’s view connected to its backing storage and represent absence or invalid boundaries explicitly. Distinguish memory safety, valid encoding, and acceptance of a meaningful message. Prefer checked, fallible access where input may be incomplete, and document the transition from raw input to borrowed byte or text views.

Before reading

  • Rust ownership and borrowing
  • Bytes versus Unicode text

Context and limits

  • The introductory text-processing example assumes ASCII.
  • Bounds-checked indexing may panic. Memory safety does not itself establish graceful error handling or valid application semantics.
  • Method stabilization versions in the API reference describe individual software APIs, not the publication or revision date of this educational resource.

Sources and provenance

  1. The Slice Type The Rust Project · reviewed 2026-10-12
  2. Slice types The Rust Project · reviewed 2026-10-12
  3. Storing UTF-8 Encoded Text with Strings The Rust Project · reviewed 2026-10-12
  4. Primitive Type slice The Rust Project · reviewed 2026-10-12

Record reviewed 2026-10-12. Snapshot cb017eaea66e. Open the complete JSON contract.

GitHub snapshot 2026-10-12

cb017eaea66e · JSON exports & schemas · CC BY 4.0 content / MIT software