summaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs
new file mode 100644
index 0000000..1e7821f
--- /dev/null
+++ b/src/util.rs
@@ -0,0 +1,8 @@
+
+
+use std::cmp::{min, max};
+
+pub fn clamp<T: Ord>(val: T, lower: T, upper: T) -> T{
+ return max(min(val, upper), lower);
+}
+