RS.CLIPPY.GET_FIRST

Using `x.get(0)` when `x.first()` or `x.front()` is simpler

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: get_first. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for usage of x.get(0) instead of x.first() or x.front().

Why is this bad?

Using x.first() for Vecs and slices or x.front() for VecDeques is easier to read and has the same result.

Example

let x = vec![2, 3, 5];
let first_element = x.get(0);

Use instead:

let x = vec![2, 3, 5];
let first_element = x.first();