pid_control/util.rs
1//! Utility module.
2//!
3//! Contains small functions not related to the core functionality, but still
4//! exposed because they might be useful elsewhere.
5
6/// Caps a value inside a certain range.
7#[inline]
8pub fn limit_range<T>(min: T, max: T, value: T) -> T
9where T: PartialOrd {
10 if value > max {
11 max
12 }
13 else if value < min {
14 min
15 } else {
16 value
17 }
18}