mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Use ExpandResult
instead of MacroResult
`MacroResult` is redundant
This commit is contained in:
parent
1542797284
commit
6a9338e979
5 changed files with 42 additions and 56 deletions
|
@ -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 }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue