Allow cond_reduce without a sub parser
diff --git a/src/parsers.rs b/src/parsers.rs
index e2af5f2..de6c168 100644
--- a/src/parsers.rs
+++ b/src/parsers.rs
@@ -328,6 +328,13 @@
/// - **Syntax:** `cond_reduce!(CONDITION, THING)`
/// - **Output:** `THING`
///
+/// The subparser may be omitted in which case it defaults to [`epsilon!`].
+///
+/// [`epsilon!`]: macro.epsilon.html
+///
+/// - **Syntax:** `cond_reduce!(CONDITION)`
+/// - **Output:** `()`
+///
/// ```rust
/// #[macro_use]
/// extern crate syn;
@@ -385,6 +392,10 @@
}
};
+ ($i:expr, $cond:expr) => {
+ cond_reduce!($i, $cond, epsilon!())
+ };
+
($i:expr, $cond:expr, $f:expr) => {
cond_reduce!($i, $cond, call!($f))
};
diff --git a/src/path.rs b/src/path.rs
index a6a1440..d5b7238 100644
--- a/src/path.rs
+++ b/src/path.rs
@@ -231,7 +231,7 @@
named!(parse -> Self, do_parse!(
colon: option!(punct!(::)) >>
segments: call!(Punctuated::<PathSegment, Token![::]>::parse_separated_nonempty) >>
- cond_reduce!(segments.first().map_or(true, |seg| seg.value().ident != "dyn"), epsilon!()) >>
+ cond_reduce!(segments.first().map_or(true, |seg| seg.value().ident != "dyn")) >>
(Path {
leading_colon: colon,
segments: segments,
diff --git a/src/ty.rs b/src/ty.rs
index 61b4a4f..9189f38 100644
--- a/src/ty.rs
+++ b/src/ty.rs
@@ -532,7 +532,7 @@
}}
) >>
// Just lifetimes like `'a + 'b` is not a TraitObject.
- cond_reduce!(at_least_one_type(&bounds), epsilon!()) >>
+ cond_reduce!(at_least_one_type(&bounds)) >>
(TypeTraitObject {
dyn_token: dyn_token,
bounds: bounds,