Skip to content
← All examples

Grade with match

Rust Branching

match with ranges

Flowchart (ISO 5807)

YesNoYesNoYesNoStartInput scorescore >= 90 && score <= 100Return «Відмінно»Endscore >= 75 && score <= 89Return «Добре»Endscore >= 60 && score <= 74Return «Задовільно»EndReturn «Незадовільно»EndFigure 1 — grade

Source code

fn grade(score: u32) -> &'static str {
    match score {
        90..=100 => "Відмінно",
        75..=89 => "Добре",
        60..=74 => "Задовільно",
        _ => "Незадовільно",
    }
}