Skip to content

Commit

Permalink
macros: Add documentation to blanket_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
The0x539 committed Mar 23, 2024
1 parent 6e4f4d8 commit 3a46f41
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ pub fn define_node(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
stream.into()
}

/// Given a trait definition such as:
/// ```
/// trait Node {
/// type ParseError;
/// const NODE_TYPE: NodeType;
/// fn source_range(&self) -> SourceRange;
/// }
/// ```
/// Generate an implementation of the form:
/// ```
/// impl<T: Node> Node for &T {
/// type ParseError = T::ParseError;
/// const NODE_TYPE: NodeType = T::NODE_TYPE;
/// fn source_range(&self) -> SourceRange {
/// T::source_range(self)
/// }
/// }
/// ```
/// A similar `impl` will be generated for `&mut T`.
#[proc_macro_attribute]
pub fn blanket_ref(
_attr: proc_macro::TokenStream,
Expand All @@ -37,6 +56,7 @@ pub fn blanket_ref(
output.into()
}

/// Like [`macro@blanket_ref`], but only generates an `impl` for `&mut T`.
#[proc_macro_attribute]
pub fn blanket_mut(
_attr: proc_macro::TokenStream,
Expand Down

0 comments on commit 3a46f41

Please sign in to comment.