diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-10-01 13:46:01 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2017-10-01 13:55:16 +0200 |
commit | 9bd8816be8d5a984edafbd63a43ea0a48e1a1717 (patch) | |
tree | 24560d6123033afda1a54f6e6b3f0d652d3ce2ce | |
parent | 488bd4c22886cc6a0b22787d46c6a57df0a0cf98 (diff) |
Add compiletets
-rw-r--r-- | src/failable/filter.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/failable/filter.rs b/src/failable/filter.rs index d2fc51c..1e07668 100644 --- a/src/failable/filter.rs +++ b/src/failable/filter.rs @@ -255,3 +255,30 @@ impl<I, E: Error, T: Fn(&I) -> Result<bool, E>> FailableFilter<I, E> for T { } } +#[cfg(test)] +mod tests { + use super::*; + + #[derive(Debug)] + struct StupError { } + + impl ::std::fmt::Display for StupError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { + Ok(()) + } + } + + impl Error for StupError { + fn description(&self) -> &str { + "stub" + } + } + + #[test] + fn compile_test() { + let a = |r: &i32| -> Result<bool, StupError> { Ok(true) }; + + assert!(a.filter(&1).unwrap()); + } +} + |