must 0.2.0

assertion library for rust
Documentation
use errors::{ErrorKind, dump};
use lazy::SimpleAssert;
use std::fmt::Debug;


/// Extension for [PartialOrd][]
///
/// [PartialOrd]:https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html
pub trait PartialOrdMust<R: Debug>: Debug + PartialOrd<R> {
	/// Must be less than
	fn must_be_lt(&self, other: R) -> SimpleAssert<&Self> {
		if self.lt(&other) {
			self.into()
		} else {
			ErrorKind::MustBeLessThan { other: dump(&other) }.but_got(self)
		}
	}

	/// Must be less than or equal
	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> {}