1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/// it's easy to overlook the `!` in `assert!(!this_is.really_eycatching())`
#[cfg(test)]
macro_rules! assert_not {
//direct forward + `!`
($($t:tt)*) => (assert!(! $($t)*));
}
#[cfg(test)]
macro_rules! assert_ok {
($val:expr) => ({
match $val {
Ok( res ) => res,
Err( err ) => panic!( "expected Ok(..) got Err({:?})", err)
}
});
($val:expr, $ctx:expr) => ({
match $val {
Ok( res ) => res,
Err( err ) => panic!( "expected Ok(..) got Err({:?}) [ctx: {:?}]", err, $ctx)
}
});
}
#[cfg(test)]
macro_rules! assert_err {
($val:expr) => ({
match $val {
Ok( val ) => panic!( "expected Err(..) got Ok({:?})", val),
Err( err ) => err,
}
});
($val:expr, $ctx:expr) => ({
match $val {
Ok( val ) => panic!( "expected Err(..) got Ok({:?}) [ctx: {:?}]", val, $ctx),
Err( err ) => err,
}
});
}
// macro_rules! deref0 {
// (+mut $name:ident => $tp:ty) => (
// deref0!{-mut $name => $tp }
// impl ::std::ops::DerefMut for $name {
// fn deref_mut( &mut self ) -> &mut Self::Target {
// &mut self.0
// }
// }
// );
// (-mut $name:ident => $tp:ty) => (
// impl ::std::ops::Deref for $name {
// type Target = $tp;
// fn deref( &self ) -> &Self::Target {
// &self.0
// }
// }
// );
// }
|