Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/lib.rs')
| -rw-r--r-- | crates/mbe/src/lib.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/mbe/src/lib.rs b/crates/mbe/src/lib.rs index e0bbb825b9..a2a6d02b8a 100644 --- a/crates/mbe/src/lib.rs +++ b/crates/mbe/src/lib.rs @@ -69,7 +69,7 @@ pub use crate::{ parse_exprs_with_sep, parse_to_token_tree, syntax_node_to_token_tree, token_tree_to_syntax_node, }, - token_map::TokenMap, + token_map::{MappedSubTree, TokenMap}, }; /// This struct contains AST for a single `macro_rules` definition. What might @@ -97,11 +97,11 @@ struct Rule { rhs: MetaTemplate, } -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -struct Shift(u32); +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub struct Shift(u32); impl Shift { - fn new(tt: &tt::Subtree) -> Shift { + pub 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); @@ -134,7 +134,7 @@ impl Shift { } /// Shift given TokenTree token id - fn shift_all(self, tt: &mut tt::Subtree) { + pub fn shift_all(self, tt: &mut tt::Subtree) { for t in &mut tt.token_trees { match t { tt::TokenTree::Leaf(leaf) => match leaf { @@ -152,14 +152,14 @@ impl Shift { } } - fn shift(self, id: tt::TokenId) -> tt::TokenId { + pub fn shift(self, id: tt::TokenId) -> tt::TokenId { if id == tt::TokenId::unspecified() { return id; } tt::TokenId(id.0 + self.0) } - fn unshift(self, id: tt::TokenId) -> Option<tt::TokenId> { + pub fn unshift(self, id: tt::TokenId) -> Option<tt::TokenId> { id.0.checked_sub(self.0).map(tt::TokenId) } } |