RS.CLIPPY.DEREF_BY_SLICING

Slicing instead of dereferencing

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

What it does

Checks for slicing expressions which are equivalent to dereferencing the value.

Why restrict this?

Some people may prefer to dereference rather than slice.

Example

let vec = vec![1, 2, 3];
let slice = &vec[..];

Use instead:

let vec = vec![1, 2, 3];
let slice = &*vec;