diff options
author | Jonas Schievink <[email protected]> | 2020-11-26 15:48:17 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-11-26 15:48:17 +0000 |
commit | 6a9338e979ed90d2c0342db2d489c37bebb62ce7 (patch) | |
tree | 260c5811fb59578cf44ff0929c4aab8b4f1773ce /crates/mbe | |
parent | 1542797284f5d3ea51d4e44c5c3c0c673d22d79a (diff) |
Use `ExpandResult` instead of `MacroResult`
`MacroResult` is redundant
Diffstat (limited to 'crates/mbe')
-rw-r--r-- | crates/mbe/src/lib.rs | 8 |
1 files changed, 8 insertions, 0 deletions
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 { | |||
33 | ConversionError, | 33 | ConversionError, |
34 | InvalidRepeat, | 34 | InvalidRepeat, |
35 | ProcMacroError(tt::ExpansionError), | 35 | ProcMacroError(tt::ExpansionError), |
36 | Other(String), | ||
36 | } | 37 | } |
37 | 38 | ||
38 | impl From<tt::ExpansionError> for ExpandError { | 39 | impl From<tt::ExpansionError> for ExpandError { |
@@ -264,6 +265,13 @@ impl<T> ExpandResult<T> { | |||
264 | Self { value: Default::default(), err: Some(err) } | 265 | Self { value: Default::default(), err: Some(err) } |
265 | } | 266 | } |
266 | 267 | ||
268 | pub fn str_err(err: String) -> Self | ||
269 | where | ||
270 | T: Default, | ||
271 | { | ||
272 | Self::only_err(ExpandError::Other(err)) | ||
273 | } | ||
274 | |||
267 | pub fn map<U>(self, f: impl FnOnce(T) -> U) -> ExpandResult<U> { | 275 | pub fn map<U>(self, f: impl FnOnce(T) -> U) -> ExpandResult<U> { |
268 | ExpandResult { value: f(self.value), err: self.err } | 276 | ExpandResult { value: f(self.value), err: self.err } |
269 | } | 277 | } |