Skip to content

Instantly share code, notes, and snippets.

@MikuroXina
Created March 27, 2021 09:16
Show Gist options
  • Select an option

  • Save MikuroXina/1fc910411a6f0b83f6bd85c96aa0b491 to your computer and use it in GitHub Desktop.

Select an option

Save MikuroXina/1fc910411a6f0b83f6bd85c96aa0b491 to your computer and use it in GitHub Desktop.
You can use with `impl` to the type you want.
trait ChMax: Sized + PartialOrd {
fn ch_max(&mut self, other: Self) {
if *self < other {
*self = other;
}
}
}
trait ChMin: Sized + PartialOrd {
fn ch_min(&mut self, other: Self) {
if other < *self {
*self = other;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment