Use ExpandResult instead of MacroResult

`MacroResult` is redundant
This commit is contained in:
Jonas Schievink 2020-11-26 16:48:17 +01:00
parent 1542797284
commit 6a9338e979
5 changed files with 42 additions and 56 deletions

View file

@ -33,6 +33,7 @@ pub enum ExpandError {
ConversionError,
InvalidRepeat,
ProcMacroError(tt::ExpansionError),
Other(String),
}
impl From<tt::ExpansionError> for ExpandError {
@ -264,6 +265,13 @@ impl<T> ExpandResult<T> {
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<U>(self, f: impl FnOnce(T) -> U) -> ExpandResult<U> {
ExpandResult { value: f(self.value), err: self.err }
}