Back to Comprehensive Rust

Exercise: Generic `min`

src/generics/exercise.md

latest664 B
Original Source
<!-- Copyright 2023 Google LLC SPDX-License-Identifier: CC-BY-4.0 -->

Exercise: Generic min

In this short exercise, you will implement a generic min function that determines the minimum of two values, using the Ord trait.

rust,editable
# // Copyright 2023 Google LLC
# // SPDX-License-Identifier: Apache-2.0
#
use std::cmp::Ordering;

// TODO: implement the `min` function used in the tests.

{{#include exercise.rs:tests}}
<details> </details>