Rust&#x27;s std::slice has a `get` method that does exactly that: <a href="http:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;primitive.slice.html#method.get" rel="nofollow">http:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;primitive.slice.html#method.get</a>