Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fmt;
- use std::any::Any;
- use std::fmt::Debug;
- pub type AssertResult = Result<(), String>;
- pub trait Assert<L: Any + Debug> {
- fn compare<R: Any + Debug>(self, target: R) -> AssertResult;
- }
- pub struct Equal<L> {
- expected: L,
- }
- impl<L> Equal<L> {
- pub fn new(expected: L) -> Equal<L> {
- Equal { expected: expected }
- }
- }
- impl<L: 'static + fmt::Debug> Assert<L> for Equal<L> {
- fn compare<R: PartialEq<L> + fmt::Debug>(self, target: R) -> AssertResult {
- if target == self.expected {
- Ok(())
- } else {
- Err(format!(
- "Expected {:?}, recei222ved {:?}",
- self.expected,
- target
- ))
- }
- }
- }
- fn main() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement