RS.CLIPPY.REF_PATTERNS

Use of a ref pattern, e.g. Some(ref value)

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

What it does

Checks for usages of the ref keyword.

Why restrict this?

The ref keyword can be confusing for people unfamiliar with it, and often it is more concise to use & instead.

Example

let opt = Some(5);
if let Some(ref foo) = opt {}

Use instead:

let opt = Some(5);
if let Some(foo) = &opt {}