summary refs log tree commit diff stats
path: root/src/pattern.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pattern.rs')
-rw-r--r--src/pattern.rs72
1 files changed, 40 insertions, 32 deletions
diff --git a/src/pattern.rs b/src/pattern.rs
index 38cdcda..23d427e 100644
--- a/src/pattern.rs
+++ b/src/pattern.rs
@@ -24,12 +24,11 @@ use crate::vm::MAX_CALLS;
 /// # Examples
 ///
 /// ```
-/// use datafu::Pattern;
+/// use datafu::PatternBuilder;
 ///
-/// let pattern = Pattern::<()>::compile::<&str, &str>(
+/// let pattern = PatternBuilder::for_pattern(
 ///     "->['value']'hello'",
-///     None, None
-/// ).expect("failed to compile pattern");
+/// ).compile().expect("failed to compile pattern");
 /// ```
 pub struct Pattern<O: Serialize> {
     consts: PatternConstants<O>,
@@ -77,34 +76,43 @@ impl<'s> PatternBuilder<'s> {
     /// # Examples
     ///
     /// ```
-    /// use datafu::Pattern;
-    /// use serde::Deserialize;
-    /// use charx;
-    ///
-    /// let preds = vec![
-    ///     ("dict", datafu::pred(|v| { todo!() })),
-    ///     ("str", datafu::pred(|v| { String::deserialize(v).is_ok() })),
-    ///     ("commit", datafu::pred(|v| {
-    ///         if let Ok(v) = String::deserialize(v) {
-    ///             v.len() == 40 && v.trim_start_matches(
-    ///                 charx::is_ascii_hexdigit
-    ///             ).is_empty()
-    ///         } else {
-    ///             false
-    ///         }
-    ///     })),
-    ///     ("uri", datafu::pred(|v| { todo!() })),
-    ///     ("bool", datafu::pred(|v| { todo!() })),
-    /// ].into_iter().collect();
-    /// let pattern = Pattern::<()>::compile::<&str, &str>("
-    ///        ->'projects':$dict
-    ///          ->commit[:?$str:?$commit]:?$dict
-    ///            ->url[:?$str:?$uri]:?$dict
-    ///              ->branch:?$dict
-    ///                (->active'active'?:?$bool)
-    ///                (->federate'federate'?:?$bool)?",
-    ///     Some(preds), None
-    /// ).expect("failed to compile pattern");
+    /// use datafu::PatternBuilder;
+    ///// use serde::Deserialize;
+    ///// use charx;
+    /////
+    ///// let preds = vec![
+    /////     ("dict", datafu::pred(|v| { todo!() })),
+    /////     ("str", datafu::pred(|v| { String::deserialize(v).is_ok() })),
+    /////     ("commit", datafu::pred(|v| {
+    /////         if let Ok(v) = String::deserialize(v) {
+    /////             v.len() == 40 && v.trim_start_matches(
+    /////                 charx::is_ascii_hexdigit
+    /////             ).is_empty()
+    /////         } else {
+    /////             false
+    /////         }
+    /////     })),
+    /////     ("uri", datafu::pred(|v| { todo!() })),
+    /////     ("bool", datafu::pred(|v| { todo!() })),
+    ///// ].into_iter().collect();
+    ///// let pattern = PatternBuilder::for_pattern("
+    /////        ->'projects':$dict
+    /////          ->commit[:?$str:?$commit]:?$dict
+    /////            ->url[:?$str:?$uri]:?$dict
+    /////              ->branch:?$dict
+    /////                (->active'active'?:?$bool)
+    /////                (->federate'federate'?:?$bool)?"
+    ///// ).compile().expect("failed to compile pattern");
+    /// let pattern = PatternBuilder::for_pattern("
+    ///     :map
+    ///     ->['projects'?]:map
+    ///       ->[commit:?str]:?map
+    ///         ->[url:?str]:?map
+    ///           ->[branch:?str]:?map
+    ///             (->['active'?]active:?bool)?
+    ///             (->['federate'?]?federate:?bool)?
+    ///             (->['pinned'?]?pinned:?bool)?
+    /// ").compile().expect("failed to compile pattern");
     /// ```
     pub fn for_pattern(pattern: &'s str) -> Self {
         Self {