Skip to main content
InterviewHubPRO
Section Overview
Q9

Question 9 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

18%
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:
    1. A pointer to the starting memory address.
    2. The length of the slice.
  • Does not own the underlying data; it is a reference.
  • &str is a string slice (view into a UTF-8 string buffer); &[i32] is a slice of an integer array or vector.