From 6a9338e979ed90d2c0342db2d489c37bebb62ce7 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 26 Nov 2020 16:48:17 +0100 Subject: Use `ExpandResult` instead of `MacroResult` `MacroResult` is redundant --- crates/mbe/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/mbe') diff --git a/crates/mbe/src/lib.rs b/crates/mbe/src/lib.rs index 183e3b988..22fbf9a80 100644 --- a/crates/mbe/src/lib.rs +++ b/crates/mbe/src/lib.rs @@ -33,6 +33,7 @@ pub enum ExpandError { ConversionError, InvalidRepeat, ProcMacroError(tt::ExpansionError), + Other(String), } impl From for ExpandError { @@ -264,6 +265,13 @@ impl ExpandResult { Self { value: Default::default(), err: Some(err) } } + pub fn str_err(err: String) -> Self + where + T: Default, + { + Self::only_err(ExpandError::Other(err)) + } + pub fn map(self, f: impl FnOnce(T) -> U) -> ExpandResult { ExpandResult { value: f(self.value), err: self.err } } -- cgit v1.2.3