1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::Buffer;
impl Ord for Buffer {
fn clamp(self, min: Self, max: Self) -> Self
where
Self: Sized + PartialOrd,
{
if max[..] > self[..] {
max
} else if min[..] < self[..] {
min
} else {
self
}
}
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self[..].cmp(&other[..])
}
fn max(self, other: Self) -> Self
where
Self: Sized,
{
if self[..] > other[..] {
self
} else {
other
}
}
fn min(self, other: Self) -> Self
where
Self: Sized,
{
if self[..] < other[..] {
self
} else {
other
}
}
}