aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-11-26 15:48:58 +0000
committerGitHub <[email protected]>2020-11-26 15:48:58 +0000
commitdb061fb274ddc9a8820c5f0c90b077c88961d1be (patch)
tree260c5811fb59578cf44ff0929c4aab8b4f1773ce /crates/mbe/src/lib.rs
parent1542797284f5d3ea51d4e44c5c3c0c673d22d79a (diff)
parent6a9338e979ed90d2c0342db2d489c37bebb62ce7 (diff)
Merge #6639
6639: Use `ExpandResult` instead of `MacroResult` r=jonas-schievink a=jonas-schievink `MacroResult` is redundant. bors r+ :robot: Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/mbe/src/lib.rs')
-rw-r--r--crates/mbe/src/lib.rs8
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
38impl From<tt::ExpansionError> for ExpandError { 39impl 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 }