aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe
diff options
context:
space:
mode:
Diffstat (limited to 'crates/mbe')
-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 }