2019-09-30 03:58:53 -05:00
|
|
|
//! `mbe` (short for Macro By Example) crate contains code for handling
|
2020-08-12 09:46:20 -05:00
|
|
|
//! `macro_rules` macros. It uses `TokenTree` (from `tt` package) as the
|
2019-09-30 03:58:53 -05:00
|
|
|
//! interface, although it contains some code to bridge `SyntaxNode`s and
|
|
|
|
//! `TokenTree`s as well!
|
2019-01-31 12:29:04 -06:00
|
|
|
|
2019-09-16 18:54:22 -05:00
|
|
|
mod parser;
|
2021-01-29 06:23:38 -06:00
|
|
|
mod expander;
|
2019-01-31 12:29:04 -06:00
|
|
|
mod syntax_bridge;
|
2019-09-16 18:54:22 -05:00
|
|
|
mod tt_iter;
|
2019-04-07 08:42:53 -05:00
|
|
|
mod subtree_source;
|
2019-01-30 14:17:32 -06:00
|
|
|
|
2020-07-11 07:57:07 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests;
|
|
|
|
|
2021-02-05 05:57:32 -06:00
|
|
|
#[cfg(test)]
|
|
|
|
mod benchmark;
|
2021-05-24 11:43:42 -05:00
|
|
|
mod token_map;
|
2021-02-05 05:57:32 -06:00
|
|
|
|
2020-11-26 09:56:22 -06:00
|
|
|
use std::fmt;
|
|
|
|
|
2020-12-29 12:35:21 -06:00
|
|
|
pub use tt::{Delimiter, DelimiterKind, Punct};
|
2019-01-30 14:25:02 -06:00
|
|
|
|
2019-09-16 18:54:22 -05:00
|
|
|
use crate::{
|
2021-02-01 14:42:37 -06:00
|
|
|
parser::{parse_pattern, parse_template, MetaTemplate, Op},
|
2019-09-16 18:54:22 -05:00
|
|
|
tt_iter::TtIter,
|
|
|
|
};
|
|
|
|
|
2019-03-02 13:20:26 -06:00
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
2019-03-03 03:40:03 -06:00
|
|
|
pub enum ParseError {
|
2021-01-29 10:21:43 -06:00
|
|
|
UnexpectedToken(String),
|
2019-03-03 05:45:30 -06:00
|
|
|
Expected(String),
|
2021-01-29 10:21:43 -06:00
|
|
|
InvalidRepeat,
|
2021-01-08 08:42:40 -06:00
|
|
|
RepetitionEmptyTokenTree,
|
2019-03-03 03:40:03 -06:00
|
|
|
}
|
|
|
|
|
2020-05-14 04:57:37 -05:00
|
|
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
2019-03-03 03:40:03 -06:00
|
|
|
pub enum ExpandError {
|
2019-03-02 13:20:26 -06:00
|
|
|
NoMatchingRule,
|
|
|
|
UnexpectedToken,
|
|
|
|
BindingError(String),
|
2019-04-18 13:47:29 -05:00
|
|
|
ConversionError,
|
2020-03-26 11:41:44 -05:00
|
|
|
ProcMacroError(tt::ExpansionError),
|
2020-11-26 12:07:53 -06:00
|
|
|
UnresolvedProcMacro,
|
2020-11-26 09:48:17 -06:00
|
|
|
Other(String),
|
2020-03-26 11:41:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<tt::ExpansionError> for ExpandError {
|
|
|
|
fn from(it: tt::ExpansionError) -> Self {
|
|
|
|
ExpandError::ProcMacroError(it)
|
|
|
|
}
|
2019-03-02 13:20:26 -06:00
|
|
|
}
|
|
|
|
|
2020-11-26 09:56:22 -06:00
|
|
|
impl fmt::Display for ExpandError {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
match self {
|
|
|
|
ExpandError::NoMatchingRule => f.write_str("no rule matches input tokens"),
|
|
|
|
ExpandError::UnexpectedToken => f.write_str("unexpected token in input"),
|
|
|
|
ExpandError::BindingError(e) => f.write_str(e),
|
|
|
|
ExpandError::ConversionError => f.write_str("could not convert tokens"),
|
2020-11-26 12:56:38 -06:00
|
|
|
ExpandError::ProcMacroError(e) => e.fmt(f),
|
2020-11-26 12:07:53 -06:00
|
|
|
ExpandError::UnresolvedProcMacro => f.write_str("unresolved proc macro"),
|
2020-11-26 09:56:22 -06:00
|
|
|
ExpandError::Other(e) => f.write_str(e),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-24 14:47:01 -05:00
|
|
|
pub use crate::{
|
|
|
|
syntax_bridge::{
|
2021-08-09 07:41:19 -05:00
|
|
|
parse_exprs_with_sep, parse_to_token_tree, syntax_node_to_token_tree,
|
2021-05-24 14:47:01 -05:00
|
|
|
token_tree_to_syntax_node,
|
|
|
|
},
|
|
|
|
token_map::TokenMap,
|
2019-04-18 13:47:29 -05:00
|
|
|
};
|
2019-01-31 04:46:40 -06:00
|
|
|
|
2019-02-11 10:07:49 -06:00
|
|
|
/// This struct contains AST for a single `macro_rules` definition. What might
|
2019-01-31 13:14:28 -06:00
|
|
|
/// be very confusing is that AST has almost exactly the same shape as
|
|
|
|
/// `tt::TokenTree`, but there's a crucial difference: in macro rules, `$ident`
|
|
|
|
/// and `$()*` have special meaning (see `Var` and `Repeat` data structures)
|
2019-03-13 08:04:28 -05:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
2019-01-31 04:40:05 -06:00
|
|
|
pub struct MacroRules {
|
2019-11-17 10:11:43 -06:00
|
|
|
rules: Vec<Rule>,
|
2019-11-04 09:22:18 -06:00
|
|
|
/// Highest id of the token we have in TokenMap
|
2019-11-17 10:11:43 -06:00
|
|
|
shift: Shift,
|
2019-01-30 14:17:32 -06:00
|
|
|
}
|
|
|
|
|
2021-01-25 15:15:47 -06:00
|
|
|
/// For Macro 2.0
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
pub struct MacroDef {
|
|
|
|
rules: Vec<Rule>,
|
|
|
|
/// Highest id of the token we have in TokenMap
|
|
|
|
shift: Shift,
|
|
|
|
}
|
|
|
|
|
2019-09-16 18:54:22 -05:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
2019-11-17 10:11:43 -06:00
|
|
|
struct Rule {
|
2020-12-29 12:35:21 -06:00
|
|
|
lhs: MetaTemplate,
|
|
|
|
rhs: MetaTemplate,
|
|
|
|
}
|
|
|
|
|
2019-11-17 10:11:43 -06:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
struct Shift(u32);
|
|
|
|
|
|
|
|
impl Shift {
|
|
|
|
fn new(tt: &tt::Subtree) -> Shift {
|
|
|
|
// Note that TokenId is started from zero,
|
|
|
|
// We have to add 1 to prevent duplication.
|
|
|
|
let value = max_id(tt).map_or(0, |it| it + 1);
|
|
|
|
return Shift(value);
|
|
|
|
|
|
|
|
// Find the max token id inside a subtree
|
|
|
|
fn max_id(subtree: &tt::Subtree) -> Option<u32> {
|
|
|
|
subtree
|
|
|
|
.token_trees
|
|
|
|
.iter()
|
|
|
|
.filter_map(|tt| match tt {
|
2019-12-13 13:37:04 -06:00
|
|
|
tt::TokenTree::Subtree(subtree) => {
|
|
|
|
let tree_id = max_id(subtree);
|
|
|
|
match subtree.delimiter {
|
|
|
|
Some(it) if it.id != tt::TokenId::unspecified() => {
|
|
|
|
Some(tree_id.map_or(it.id.0, |t| t.max(it.id.0)))
|
|
|
|
}
|
|
|
|
_ => tree_id,
|
|
|
|
}
|
|
|
|
}
|
2019-11-17 10:11:43 -06:00
|
|
|
tt::TokenTree::Leaf(tt::Leaf::Ident(ident))
|
|
|
|
if ident.id != tt::TokenId::unspecified() =>
|
|
|
|
{
|
|
|
|
Some(ident.id.0)
|
|
|
|
}
|
|
|
|
_ => None,
|
|
|
|
})
|
|
|
|
.max()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Shift given TokenTree token id
|
|
|
|
fn shift_all(self, tt: &mut tt::Subtree) {
|
2021-06-07 06:59:01 -05:00
|
|
|
for t in &mut tt.token_trees {
|
2019-11-17 10:11:43 -06:00
|
|
|
match t {
|
|
|
|
tt::TokenTree::Leaf(leaf) => match leaf {
|
|
|
|
tt::Leaf::Ident(ident) => ident.id = self.shift(ident.id),
|
2019-12-13 13:37:04 -06:00
|
|
|
tt::Leaf::Punct(punct) => punct.id = self.shift(punct.id),
|
|
|
|
tt::Leaf::Literal(lit) => lit.id = self.shift(lit.id),
|
2019-11-17 10:11:43 -06:00
|
|
|
},
|
2019-12-13 13:37:04 -06:00
|
|
|
tt::TokenTree::Subtree(tt) => {
|
2019-12-20 14:14:30 -06:00
|
|
|
if let Some(it) = tt.delimiter.as_mut() {
|
|
|
|
it.id = self.shift(it.id);
|
|
|
|
};
|
2019-12-13 13:37:04 -06:00
|
|
|
self.shift_all(tt)
|
|
|
|
}
|
2019-11-04 11:01:05 -06:00
|
|
|
}
|
2019-11-17 10:11:43 -06:00
|
|
|
}
|
|
|
|
}
|
2019-11-04 09:22:18 -06:00
|
|
|
|
2019-11-17 10:11:43 -06:00
|
|
|
fn shift(self, id: tt::TokenId) -> tt::TokenId {
|
|
|
|
if id == tt::TokenId::unspecified() {
|
|
|
|
return id;
|
2019-11-04 09:22:18 -06:00
|
|
|
}
|
2019-11-17 10:11:43 -06:00
|
|
|
tt::TokenId(id.0 + self.0)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn unshift(self, id: tt::TokenId) -> Option<tt::TokenId> {
|
|
|
|
id.0.checked_sub(self.0).map(tt::TokenId)
|
2019-11-04 09:22:18 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-14 11:46:39 -06:00
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
2019-11-17 10:11:43 -06:00
|
|
|
pub enum Origin {
|
|
|
|
Def,
|
|
|
|
Call,
|
|
|
|
}
|
|
|
|
|
2019-01-31 13:14:28 -06:00
|
|
|
impl MacroRules {
|
2019-03-03 03:40:03 -06:00
|
|
|
pub fn parse(tt: &tt::Subtree) -> Result<MacroRules, ParseError> {
|
2019-09-22 15:39:29 -05:00
|
|
|
// Note: this parsing can be implemented using mbe machinery itself, by
|
|
|
|
// matching against `$($lhs:tt => $rhs:tt);*` pattern, but implementing
|
|
|
|
// manually seems easier.
|
2019-09-16 18:54:22 -05:00
|
|
|
let mut src = TtIter::new(tt);
|
|
|
|
let mut rules = Vec::new();
|
|
|
|
while src.len() > 0 {
|
2021-01-25 15:15:47 -06:00
|
|
|
let rule = Rule::parse(&mut src, true)?;
|
2019-09-16 18:54:22 -05:00
|
|
|
rules.push(rule);
|
|
|
|
if let Err(()) = src.expect_char(';') {
|
|
|
|
if src.len() > 0 {
|
2020-12-29 12:35:21 -06:00
|
|
|
return Err(ParseError::Expected("expected `;`".to_string()));
|
2019-09-16 18:54:22 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-09-22 15:39:29 -05:00
|
|
|
|
2021-06-07 06:59:01 -05:00
|
|
|
for rule in &rules {
|
2019-09-22 15:39:29 -05:00
|
|
|
validate(&rule.lhs)?;
|
|
|
|
}
|
|
|
|
|
2019-11-17 10:11:43 -06:00
|
|
|
Ok(MacroRules { rules, shift: Shift::new(tt) })
|
2019-01-31 13:14:28 -06:00
|
|
|
}
|
2019-11-04 09:22:18 -06:00
|
|
|
|
2020-03-13 07:03:31 -05:00
|
|
|
pub fn expand(&self, tt: &tt::Subtree) -> ExpandResult<tt::Subtree> {
|
2019-11-04 09:22:18 -06:00
|
|
|
// apply shift
|
|
|
|
let mut tt = tt.clone();
|
2019-11-17 10:11:43 -06:00
|
|
|
self.shift.shift_all(&mut tt);
|
2021-01-29 06:23:38 -06:00
|
|
|
expander::expand_rules(&self.rules, &tt)
|
2021-01-25 15:15:47 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn map_id_down(&self, id: tt::TokenId) -> tt::TokenId {
|
|
|
|
self.shift.shift(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn map_id_up(&self, id: tt::TokenId) -> (tt::TokenId, Origin) {
|
|
|
|
match self.shift.unshift(id) {
|
|
|
|
Some(id) => (id, Origin::Call),
|
|
|
|
None => (id, Origin::Def),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl MacroDef {
|
|
|
|
pub fn parse(tt: &tt::Subtree) -> Result<MacroDef, ParseError> {
|
|
|
|
let mut src = TtIter::new(tt);
|
|
|
|
let mut rules = Vec::new();
|
|
|
|
|
|
|
|
if Some(tt::DelimiterKind::Brace) == tt.delimiter_kind() {
|
2021-03-08 14:19:44 -06:00
|
|
|
cov_mark::hit!(parse_macro_def_rules);
|
2021-01-25 15:15:47 -06:00
|
|
|
while src.len() > 0 {
|
|
|
|
let rule = Rule::parse(&mut src, true)?;
|
|
|
|
rules.push(rule);
|
2021-04-02 20:08:31 -05:00
|
|
|
if let Err(()) = src.expect_any_char(&[';', ',']) {
|
2021-01-25 15:15:47 -06:00
|
|
|
if src.len() > 0 {
|
2021-04-02 20:08:31 -05:00
|
|
|
return Err(ParseError::Expected(
|
|
|
|
"expected `;` or `,` to delimit rules".to_string(),
|
|
|
|
));
|
2021-01-25 15:15:47 -06:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2021-03-08 14:19:44 -06:00
|
|
|
cov_mark::hit!(parse_macro_def_simple);
|
2021-01-25 15:15:47 -06:00
|
|
|
let rule = Rule::parse(&mut src, false)?;
|
|
|
|
if src.len() != 0 {
|
|
|
|
return Err(ParseError::Expected("remain tokens in macro def".to_string()));
|
|
|
|
}
|
|
|
|
rules.push(rule);
|
|
|
|
}
|
2021-06-07 06:59:01 -05:00
|
|
|
for rule in &rules {
|
2021-01-25 15:15:47 -06:00
|
|
|
validate(&rule.lhs)?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(MacroDef { rules, shift: Shift::new(tt) })
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn expand(&self, tt: &tt::Subtree) -> ExpandResult<tt::Subtree> {
|
|
|
|
// apply shift
|
|
|
|
let mut tt = tt.clone();
|
|
|
|
self.shift.shift_all(&mut tt);
|
2021-01-29 06:23:38 -06:00
|
|
|
expander::expand_rules(&self.rules, &tt)
|
2019-01-31 13:14:28 -06:00
|
|
|
}
|
2019-11-04 12:09:16 -06:00
|
|
|
|
2019-11-17 10:11:43 -06:00
|
|
|
pub fn map_id_down(&self, id: tt::TokenId) -> tt::TokenId {
|
|
|
|
self.shift.shift(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn map_id_up(&self, id: tt::TokenId) -> (tt::TokenId, Origin) {
|
|
|
|
match self.shift.unshift(id) {
|
|
|
|
Some(id) => (id, Origin::Call),
|
|
|
|
None => (id, Origin::Def),
|
|
|
|
}
|
2019-11-04 12:09:16 -06:00
|
|
|
}
|
2019-01-31 13:14:28 -06:00
|
|
|
}
|
|
|
|
|
2019-09-16 18:54:22 -05:00
|
|
|
impl Rule {
|
2021-06-07 06:59:01 -05:00
|
|
|
fn parse(src: &mut TtIter, expect_arrow: bool) -> Result<Self, ParseError> {
|
2020-12-30 12:38:40 -06:00
|
|
|
let lhs = src
|
2019-09-16 18:54:22 -05:00
|
|
|
.expect_subtree()
|
2020-12-30 12:38:40 -06:00
|
|
|
.map_err(|()| ParseError::Expected("expected subtree".to_string()))?;
|
2021-01-25 15:15:47 -06:00
|
|
|
if expect_arrow {
|
|
|
|
src.expect_char('=').map_err(|()| ParseError::Expected("expected `=`".to_string()))?;
|
|
|
|
src.expect_char('>').map_err(|()| ParseError::Expected("expected `>`".to_string()))?;
|
|
|
|
}
|
2020-12-30 12:38:40 -06:00
|
|
|
let rhs = src
|
2019-09-16 18:54:22 -05:00
|
|
|
.expect_subtree()
|
2020-12-30 12:38:40 -06:00
|
|
|
.map_err(|()| ParseError::Expected("expected subtree".to_string()))?;
|
2020-12-29 12:35:21 -06:00
|
|
|
|
2021-06-12 22:54:16 -05:00
|
|
|
let lhs = MetaTemplate(parse_pattern(lhs)?);
|
|
|
|
let rhs = MetaTemplate(parse_template(rhs)?);
|
2020-12-29 12:35:21 -06:00
|
|
|
|
2019-09-16 18:54:22 -05:00
|
|
|
Ok(crate::Rule { lhs, rhs })
|
|
|
|
}
|
2019-04-24 10:01:32 -05:00
|
|
|
}
|
2019-05-02 10:23:14 -05:00
|
|
|
|
2020-12-29 12:35:21 -06:00
|
|
|
fn validate(pattern: &MetaTemplate) -> Result<(), ParseError> {
|
|
|
|
for op in pattern.iter() {
|
2019-09-16 18:54:22 -05:00
|
|
|
match op {
|
2021-06-12 22:54:16 -05:00
|
|
|
Op::Subtree { tokens, .. } => validate(tokens)?,
|
2021-01-30 02:12:30 -06:00
|
|
|
Op::Repeat { tokens: subtree, separator, .. } => {
|
2020-04-25 10:09:20 -05:00
|
|
|
// Checks that no repetition which could match an empty token
|
|
|
|
// https://github.com/rust-lang/rust/blob/a58b1ed44f5e06976de2bdc4d7dc81c36a96934f/src/librustc_expand/mbe/macro_rules.rs#L558
|
|
|
|
|
2021-06-03 05:46:56 -05:00
|
|
|
if separator.is_none()
|
|
|
|
&& subtree.iter().all(|child_op| {
|
2021-01-29 10:21:43 -06:00
|
|
|
match child_op {
|
|
|
|
Op::Var { kind, .. } => {
|
2020-04-25 10:09:20 -05:00
|
|
|
// vis is optional
|
2020-12-29 12:35:21 -06:00
|
|
|
if kind.as_ref().map_or(false, |it| it == "vis") {
|
2020-04-25 10:09:20 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2021-01-29 10:21:43 -06:00
|
|
|
Op::Repeat { kind, .. } => {
|
2020-04-25 10:09:20 -05:00
|
|
|
return matches!(
|
|
|
|
kind,
|
|
|
|
parser::RepeatKind::ZeroOrMore | parser::RepeatKind::ZeroOrOne
|
|
|
|
)
|
|
|
|
}
|
2021-01-29 10:21:43 -06:00
|
|
|
Op::Leaf(_) => {}
|
2021-01-30 02:12:30 -06:00
|
|
|
Op::Subtree { .. } => {}
|
2020-04-25 10:09:20 -05:00
|
|
|
}
|
|
|
|
false
|
2021-06-03 05:46:56 -05:00
|
|
|
})
|
|
|
|
{
|
|
|
|
return Err(ParseError::RepetitionEmptyTokenTree);
|
2020-04-25 10:09:20 -05:00
|
|
|
}
|
2019-09-16 18:54:22 -05:00
|
|
|
validate(subtree)?
|
2019-05-02 10:23:14 -05:00
|
|
|
}
|
2019-09-16 18:54:22 -05:00
|
|
|
_ => (),
|
2019-05-02 10:23:14 -05:00
|
|
|
}
|
|
|
|
}
|
2019-09-16 18:54:22 -05:00
|
|
|
Ok(())
|
2019-01-30 14:25:02 -06:00
|
|
|
}
|
2019-01-31 13:14:28 -06:00
|
|
|
|
2020-11-26 09:04:23 -06:00
|
|
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
|
|
|
pub struct ExpandResult<T> {
|
|
|
|
pub value: T,
|
|
|
|
pub err: Option<ExpandError>,
|
|
|
|
}
|
2020-03-16 06:22:10 -05:00
|
|
|
|
|
|
|
impl<T> ExpandResult<T> {
|
2020-11-26 09:04:23 -06:00
|
|
|
pub fn ok(value: T) -> Self {
|
|
|
|
Self { value, err: None }
|
2020-03-16 06:22:10 -05:00
|
|
|
}
|
|
|
|
|
2020-11-26 09:04:23 -06:00
|
|
|
pub fn only_err(err: ExpandError) -> Self
|
2020-03-16 06:22:10 -05:00
|
|
|
where
|
|
|
|
T: Default,
|
|
|
|
{
|
2020-11-26 09:04:23 -06:00
|
|
|
Self { value: Default::default(), err: Some(err) }
|
2020-03-16 06:22:10 -05:00
|
|
|
}
|
|
|
|
|
2020-11-26 09:48:17 -06:00
|
|
|
pub fn str_err(err: String) -> Self
|
|
|
|
where
|
|
|
|
T: Default,
|
|
|
|
{
|
|
|
|
Self::only_err(ExpandError::Other(err))
|
|
|
|
}
|
|
|
|
|
2020-03-16 06:22:10 -05:00
|
|
|
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> ExpandResult<U> {
|
2020-11-26 09:04:23 -06:00
|
|
|
ExpandResult { value: f(self.value), err: self.err }
|
2020-03-16 06:22:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn result(self) -> Result<T, ExpandError> {
|
2021-06-07 06:59:01 -05:00
|
|
|
self.err.map_or(Ok(self.value), Err)
|
2020-03-16 06:22:10 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: Default> From<Result<T, ExpandError>> for ExpandResult<T> {
|
2020-11-26 09:04:23 -06:00
|
|
|
fn from(result: Result<T, ExpandError>) -> Self {
|
2021-03-21 09:33:18 -05:00
|
|
|
result.map_or_else(Self::only_err, Self::ok)
|
2020-03-16 06:22:10 -05:00
|
|
|
}
|
|
|
|
}
|