More code refactoring to integrate Duration (#8322)

* More code refactoring to integrate Duration

* Fix typo

* Fix tests

* More test fix
This commit is contained in:
Pierre Krieger
2018-04-14 21:35:58 +02:00
committed by Marek Kotewicz
parent 90eb61091a
commit fac356c701
28 changed files with 185 additions and 147 deletions

View File

@@ -44,6 +44,18 @@ pub struct OutOfBounds<T> {
pub found: T,
}
impl<T> OutOfBounds<T> {
pub fn map<F, U>(self, map: F) -> OutOfBounds<U>
where F: Fn(T) -> U
{
OutOfBounds {
min: self.min.map(&map),
max: self.max.map(&map),
found: map(self.found),
}
}
}
impl<T: fmt::Display> fmt::Display for OutOfBounds<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let msg = match (self.min.as_ref(), self.max.as_ref()) {