use errors::{ErrorKind, dump};
use lazy::SimpleAssert;
use std::fmt::Debug;
pub trait PartialOrdMust<R: Debug>: Debug + PartialOrd<R> {
fn must_be_lt(&self, other: R) -> SimpleAssert<&Self> {
if self.lt(&other) {
self.into()
} else {
ErrorKind::MustBeLessThan { other: dump(&other) }.but_got(self)
}
}
fn must_be_le(&self, other: R) -> SimpleAssert<&Self> {
if self.le(&other) {
self.into()
} else {
ErrorKind::MustBeLessThanOrEqual { other: dump(&other) }.but_got(self)
}
}
fn must_be_gt(&self, other: R) -> SimpleAssert<&Self> {
if self.gt(&other) {
self.into()
} else {
ErrorKind::MustBeGreaterThan { other: dump(&other) }.but_got(self)
}
}
fn must_be_ge(&self, other: R) -> SimpleAssert<&Self> {
if self.ge(&other) {
self.into()
} else {
ErrorKind::MustBeGreaterThanOrEqual { other: dump(&other) }.but_got(self)
}
}
}
impl<V: ?Sized, R: Debug> PartialOrdMust<R> for V where V: Debug + PartialOrd<R> {}