Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 809 Bytes

min-max.md

File metadata and controls

29 lines (22 loc) · 809 Bytes
title timestamp author published description tags
Which value is smaller? Which is bigger? minimum and maximum in Rust
2023-11-22 02:40:01 -0800
szabgab
true
Compare two numbers or two strings and tell us which is bigger and which is smaller.
min
max
cmp

As I was trying to figure out how to get the minimum and maximum value from a vector I bumped into the min and max functions that work on two values and can tell use which is the smaller and which is the bigger value.

In this example you can see them working on integers and on strings.

{% include file="examples/min-max/src/main.rs" %}

min: 3
max: 5
min: hello
max: world