summary refs log tree commit diff stats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8fa727f..a3a6e1e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -106,15 +106,34 @@ mod vm;
 pub use pattern::Pattern;
 
 /// A predicate.
-pub type Predicate = dyn (for<'x, 'de, 'a> Fn(
-    &'x (dyn 'a + erased_serde::Deserializer<'de>)
+pub type Predicate = dyn (Fn(
+    &mut dyn erased_serde::Deserializer<>
 ) -> bool) + Send + Sync;
 
-/// Helper to build predicates because HRTB inference is the worst.
+/// Helper to build predicates because closure inference is the worst.
+///
+/// # Examples
+///
+/// This doesn't work:
+///
+/// ```rust compile_fail
+/// use serde::Deserialize;
+/// use datafu::Predicate;
+///
+/// let x = Box::new(|v| String::deserialize(v).is_ok()) as Box<Predicate>;
+/// ```
+///
+/// But this does:
+///
+/// ```rust
+/// use serde::Deserialize;
+///
+/// let x = datafu::pred(|v| String::deserialize(v).is_ok());
+/// ```
 pub fn pred<F>(f: F) -> Box<Predicate>
 where
-    F: (for<'x, 'de, 'a> Fn(
-        &'x (dyn 'a + erased_serde::Deserializer<'de>)
+    F: (Fn(
+        &mut dyn erased_serde::Deserializer<>
     ) -> bool) +  Send + Sync + 'static,
 {
     Box::new(f)