Fix type inference snafu with synom map
diff --git a/synom/src/lib.rs b/synom/src/lib.rs
index de48e0d..7ad3b30 100644
--- a/synom/src/lib.rs
+++ b/synom/src/lib.rs
@@ -194,7 +194,7 @@
///
/// // Or equivalently:
/// named!(if_condition2 -> Expr,
-/// map!(syn!(ExprIf), |if_: ExprIf| *if_.cond)
+/// map!(syn!(ExprIf), |if_| *if_.cond)
/// );
/// #
/// # fn main() {}
@@ -206,7 +206,7 @@
::std::result::Result::Err(err) =>
::std::result::Result::Err(err),
::std::result::Result::Ok((i, o)) =>
- ::std::result::Result::Ok((i, call!(o, $g))),
+ ::std::result::Result::Ok((i, $crate::invoke($g, o))),
}
};
@@ -215,6 +215,14 @@
};
}
+// Somehow this helps with type inference in `map!`.
+//
+// Not public API.
+#[doc(hidden)]
+pub fn invoke<T, R, F: FnOnce(T) -> R>(f: F, t: T) -> R {
+ f(t)
+}
+
/// Parses successfully if the given parser fails to parse. Does not consume any
/// of the input.
///