Improvements in macros

This commit is contained in:
Andrew Golovashevich 2025-11-23 21:02:29 +03:00
parent c974074a64
commit 8388ea0657
2 changed files with 66 additions and 10 deletions

View File

@ -7,7 +7,7 @@ macro_rules! builder_type_t {
>)?
) => {
$name
$name $(:: $path)*
<
'source, 'pos, P, CS
$(, $generic0Name $(, $genericNName)*)?
@ -15,13 +15,13 @@ macro_rules! builder_type_t {
};
(
$name:ident
$name:ident $(:: $path:ident)*
<
$lifetime0Name:lifetime $(, $lifetimeNName:lifetime)*
$(, $genericNName:ty)* $(,)?
>
) => {
$name
$($path ::)* $name $(:: $path)*
<
'source, 'pos, $lifetime0Name $(, $lifetimeNName)*,
P, CS $(, $genericNName)*
@ -29,13 +29,13 @@ macro_rules! builder_type_t {
};
(
impl $name:ident
impl $name:ident $(:: $path:ident)*
$(<
$generic0Name:ty $(, $genericNName:ty)* $(,)?
>)?
) => {
impl $name
impl $name $(:: $path)*
<
'source, 'pos, P, CS
$(, $generic0Name $(, $genericNName)*)?
@ -43,13 +43,69 @@ macro_rules! builder_type_t {
};
(
impl $name:ident
impl $name:ident $(:: $path:ident)*
<
$lifetime0Name:lifetime $(, $lifetimeNName:lifetime)*
$(, $genericNName:ty)* $(,)?
>
) => {
impl $name
impl $name $(:: $path)*
<
'source, 'pos, $lifetime0Name $(, $lifetimeNName)*,
P, CS $(, $genericNName)*
>
};
(
&impl $name:ident $(:: $path:ident)*
$(<
$generic0Name:ty $(, $genericNName:ty)* $(,)?
>)?
) => {
&impl $name $(:: $path)*
<
'source, 'pos, P, CS
$(, $generic0Name $(, $genericNName)*)?
>
};
(
&impl $name:ident $(:: $path:ident)*
<
$lifetime0Name:lifetime $(, $lifetimeNName:lifetime)*
$(, $genericNName:ty)* $(,)?
>
) => {
&impl $name $(:: $path)*
<
'source, 'pos, $lifetime0Name $(, $lifetimeNName)*,
P, CS $(, $genericNName)*
>
};
(
&mut impl $name:ident $(:: $path:ident)*
$(<
$generic0Name:ty $(, $genericNName:ty)* $(,)?
>)?
) => {
&mut impl $name $(:: $path)*
<
'source, 'pos, P, CS
$(, $generic0Name $(, $genericNName)*)?
>
};
(
&mut impl $name:ident $(:: $path:ident)*
<
$lifetime0Name:lifetime $(, $lifetimeNName:lifetime)*
$(, $genericNName:ty)* $(,)?
>
) => {
&mut impl $name $(:: $path)*
<
'source, 'pos, $lifetime0Name $(, $lifetimeNName)*,
P, CS $(, $genericNName)*

View File

@ -89,7 +89,7 @@ macro_rules! parser_fn_decl {
$(, $genericName $(: $genericBound)?)*
>
(
$srcName: &'source mut impl SourceStream<'source, 'pos, C=C, P=P, CS=CS>
$srcName: &mut impl SourceStream<'source, 'pos, C=C, P=P, CS=CS>
$(, $argName : $argType)*
)
$(-> $ret)?
@ -121,7 +121,7 @@ macro_rules! parser_fn_decl {
$(, $genericName $(: $genericBound)?)*
>
(
$srcName: &'source mut impl SourceStream<'source, 'pos, C=$charType, P=P, CS=CS>
$srcName: &mut impl SourceStream<'source, 'pos, C=$charType, P=P, CS=CS>
$(, $argName : $argType)*
)
$(-> $ret)?