Rust Systems & Tokio (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is a Slice (`&[T]` and `&str`)?
junior LevelrustBasic
In Simple Words: A slice is a two-word view into a contiguous sequence of elements in memory:
- Contains:
- A pointer to the starting memory address.
- The length of the slice.
- Does not own the underlying data; it is a reference.
&stris a string slice (view into a UTF-8 string buffer);&[i32]is a slice of an integer array or vector.