std-module

std::cmp — comparisons and ordering

This module provides comparison traits and helpers for choosing or ordering values. Use Ord for a total ordering; not every type can support it. Expected stdout (not executed): 8 Common mistake: Assuming every type with == can also be totally ordered.

Formal Syntax & Structure

rust syntaxrust
use std::cmp::{min, max, Ordering};

Working Example

Example Snippetrust
fn main() {    let delivery = std::cmp::min(12, 8);    println!("{delivery}");}
Rust Reference