How Rust Knows When You're Not Using a Variable: The _ Prefix Trick
By Ugochukwu Chizaram Omumusinachi · Updated Mon Jun 02 2025In no more than 5 minutes we'll show you the difference between an empty binding and a named silenced binding and when to use them.
In Rust, aside from variables and struct fields, you can also bind memory to patterns. Some of these patterns are used by the compiler to signal certain conditions, like when a variable will never be used or when it may be used. This is the point of this article: how does the Rust compiler know you'll use a variable?
It all boils down to the _ and _variable_name patterns, which we call empty binding and named silenced bindings respectively. With these two patterns, Rust can know if you intend on using a variable even though you haven't used it yet (in your current code structure) or you don't have any expected usage of that variable.

Although these two patterns seem alike, as their aliases imply, they're not the same. Let's look at some of the purposes and differences between both.