Skip to content
masterclass Buddy

Rust · Macro

matches!

The Rust matches! macro checks whether an expression fits a pattern. It returns false when an optional guard is not true.

Last updated

Since
1.42.0

Syntax

matches!(expression, pattern [if guard])

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • assert_matches!
  • match

Source: matches in std - Rust. Checked 2026-11-03.