Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


Definition: Scrutinee

Educative Answers Team

Scrutinee are expressions used in pattern matching constructs in Rust – they are, for example, part of match and if-let expressions. In the code below, on line four, where match x, x is the scrutinee.

fn main() {
  let x = 1;

  match x {
      1 => println!("one"),
      2 => println!("two"),
      3 => println!("three"),
      _ => println!("something else"),
Tip: You can edit the code above to try other options

Learn more about the match expression here.

The syntax of if-let expressions is, let <name> = <scrutinee>. So, in the example below, let beverage = ("tea","coffee") is the scrutinee.

fn main() {
  let beverage = ("tea","coffee");

    // this body will be skipped because the pattern is refuted
    if let ("coffee", b) = beverage {
        println!("tea, not {}", b);
    } else {
        // This block is evaluated instead.
        println!("No I'll just have tea.");

    // this body will execute
    if let ("tea", b) = beverage {
        println!("tea, not {}", b)

    if let _ = 5 {
        println!("Irrefutable patterns are always true");

Learn more about the if-let expression here.


Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring