Struct attr_parser_fn::ParseArgs
source · pub struct ParseArgs<ReqArgs, OptArgs, RestArgs, Meta> {
pub args: ReqArgs,
pub opt_args: OptArgs,
pub rest_args: RestArgs,
pub meta: Meta,
}Fields§
§args: ReqArgs§opt_args: OptArgs§rest_args: RestArgs§meta: MetaImplementations§
source§impl ParseArgs<Marker<()>, Marker<()>, Marker<()>, ()>
impl ParseArgs<Marker<()>, Marker<()>, Marker<()>, ()>
sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/test.rs (line 21)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
fn main() {
let attr: Attribute = parse_quote! {
#[my_attr(
"hello",
"world",
122,
conf1 = 114 + 514,
key_value = SomeType<A, B>,
path_only,
nested(tea(green_tea)))
]
};
let parser = ParseArgs::new()
.args::<(LitStr, LitStr)>()
.opt_args::<(Lit, Lit)>()
.rest_args::<Vec<Lit>>()
.meta((
("path_only", path_only()),
("key_value", key_value::<Type>()),
("kv_optional", key_value::<Expr>()).optional(),
conflicts((
("conf1", path_only()).value("conf1"),
("conf1", key_value::<Expr>()).value("conf1_expr"),
("conf2", key_value::<Expr>()).value("conf2"),
)),
(
"nested",
meta_list((
("milk", path_only()),
(
"tea",
meta_list(conflicts((
("red_tea", path_only()).value("red_tea"),
("green_tea", path_only()).value("green_tea"),
))),
),
)),
),
));
let ParseArgs {
args: (_, _), // ("hello", "world")
opt_args: (Some(_), None), // (Some(112), None)
rest_args: _, // []
meta:
(
true,
_, // SomeType<A, B>
None,
"conf1_expr",
(false, "green_tea"),
),
} = parser.parse_attrs(&attr).unwrap()
else {
unreachable!()
};
}source§impl<ReqArgs, OptArgs, RestArgs, Meta> ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
impl<ReqArgs, OptArgs, RestArgs, Meta> ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
sourcepub fn args<T: ParseRequiredArgs>(
self,
) -> ParseArgs<Marker<T>, OptArgs, RestArgs, Meta>
pub fn args<T: ParseRequiredArgs>( self, ) -> ParseArgs<Marker<T>, OptArgs, RestArgs, Meta>
Examples found in repository?
examples/test.rs (line 22)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
fn main() {
let attr: Attribute = parse_quote! {
#[my_attr(
"hello",
"world",
122,
conf1 = 114 + 514,
key_value = SomeType<A, B>,
path_only,
nested(tea(green_tea)))
]
};
let parser = ParseArgs::new()
.args::<(LitStr, LitStr)>()
.opt_args::<(Lit, Lit)>()
.rest_args::<Vec<Lit>>()
.meta((
("path_only", path_only()),
("key_value", key_value::<Type>()),
("kv_optional", key_value::<Expr>()).optional(),
conflicts((
("conf1", path_only()).value("conf1"),
("conf1", key_value::<Expr>()).value("conf1_expr"),
("conf2", key_value::<Expr>()).value("conf2"),
)),
(
"nested",
meta_list((
("milk", path_only()),
(
"tea",
meta_list(conflicts((
("red_tea", path_only()).value("red_tea"),
("green_tea", path_only()).value("green_tea"),
))),
),
)),
),
));
let ParseArgs {
args: (_, _), // ("hello", "world")
opt_args: (Some(_), None), // (Some(112), None)
rest_args: _, // []
meta:
(
true,
_, // SomeType<A, B>
None,
"conf1_expr",
(false, "green_tea"),
),
} = parser.parse_attrs(&attr).unwrap()
else {
unreachable!()
};
}sourcepub fn opt_args<T: ParseOptionalArgs>(
self,
) -> ParseArgs<ReqArgs, Marker<T>, RestArgs, Meta>
pub fn opt_args<T: ParseOptionalArgs>( self, ) -> ParseArgs<ReqArgs, Marker<T>, RestArgs, Meta>
Examples found in repository?
examples/test.rs (line 23)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
fn main() {
let attr: Attribute = parse_quote! {
#[my_attr(
"hello",
"world",
122,
conf1 = 114 + 514,
key_value = SomeType<A, B>,
path_only,
nested(tea(green_tea)))
]
};
let parser = ParseArgs::new()
.args::<(LitStr, LitStr)>()
.opt_args::<(Lit, Lit)>()
.rest_args::<Vec<Lit>>()
.meta((
("path_only", path_only()),
("key_value", key_value::<Type>()),
("kv_optional", key_value::<Expr>()).optional(),
conflicts((
("conf1", path_only()).value("conf1"),
("conf1", key_value::<Expr>()).value("conf1_expr"),
("conf2", key_value::<Expr>()).value("conf2"),
)),
(
"nested",
meta_list((
("milk", path_only()),
(
"tea",
meta_list(conflicts((
("red_tea", path_only()).value("red_tea"),
("green_tea", path_only()).value("green_tea"),
))),
),
)),
),
));
let ParseArgs {
args: (_, _), // ("hello", "world")
opt_args: (Some(_), None), // (Some(112), None)
rest_args: _, // []
meta:
(
true,
_, // SomeType<A, B>
None,
"conf1_expr",
(false, "green_tea"),
),
} = parser.parse_attrs(&attr).unwrap()
else {
unreachable!()
};
}sourcepub fn rest_args<T: ParseRestArgs>(
self,
) -> ParseArgs<ReqArgs, OptArgs, Marker<T>, Meta>
pub fn rest_args<T: ParseRestArgs>( self, ) -> ParseArgs<ReqArgs, OptArgs, Marker<T>, Meta>
Examples found in repository?
examples/test.rs (line 24)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
fn main() {
let attr: Attribute = parse_quote! {
#[my_attr(
"hello",
"world",
122,
conf1 = 114 + 514,
key_value = SomeType<A, B>,
path_only,
nested(tea(green_tea)))
]
};
let parser = ParseArgs::new()
.args::<(LitStr, LitStr)>()
.opt_args::<(Lit, Lit)>()
.rest_args::<Vec<Lit>>()
.meta((
("path_only", path_only()),
("key_value", key_value::<Type>()),
("kv_optional", key_value::<Expr>()).optional(),
conflicts((
("conf1", path_only()).value("conf1"),
("conf1", key_value::<Expr>()).value("conf1_expr"),
("conf2", key_value::<Expr>()).value("conf2"),
)),
(
"nested",
meta_list((
("milk", path_only()),
(
"tea",
meta_list(conflicts((
("red_tea", path_only()).value("red_tea"),
("green_tea", path_only()).value("green_tea"),
))),
),
)),
),
));
let ParseArgs {
args: (_, _), // ("hello", "world")
opt_args: (Some(_), None), // (Some(112), None)
rest_args: _, // []
meta:
(
true,
_, // SomeType<A, B>
None,
"conf1_expr",
(false, "green_tea"),
),
} = parser.parse_attrs(&attr).unwrap()
else {
unreachable!()
};
}sourcepub fn meta<T: ParseMeta>(
self,
meta: T,
) -> ParseArgs<ReqArgs, OptArgs, RestArgs, T>
pub fn meta<T: ParseMeta>( self, meta: T, ) -> ParseArgs<ReqArgs, OptArgs, RestArgs, T>
Examples found in repository?
examples/test.rs (lines 25-47)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
fn main() {
let attr: Attribute = parse_quote! {
#[my_attr(
"hello",
"world",
122,
conf1 = 114 + 514,
key_value = SomeType<A, B>,
path_only,
nested(tea(green_tea)))
]
};
let parser = ParseArgs::new()
.args::<(LitStr, LitStr)>()
.opt_args::<(Lit, Lit)>()
.rest_args::<Vec<Lit>>()
.meta((
("path_only", path_only()),
("key_value", key_value::<Type>()),
("kv_optional", key_value::<Expr>()).optional(),
conflicts((
("conf1", path_only()).value("conf1"),
("conf1", key_value::<Expr>()).value("conf1_expr"),
("conf2", key_value::<Expr>()).value("conf2"),
)),
(
"nested",
meta_list((
("milk", path_only()),
(
"tea",
meta_list(conflicts((
("red_tea", path_only()).value("red_tea"),
("green_tea", path_only()).value("green_tea"),
))),
),
)),
),
));
let ParseArgs {
args: (_, _), // ("hello", "world")
opt_args: (Some(_), None), // (Some(112), None)
rest_args: _, // []
meta:
(
true,
_, // SomeType<A, B>
None,
"conf1_expr",
(false, "green_tea"),
),
} = parser.parse_attrs(&attr).unwrap()
else {
unreachable!()
};
}Trait Implementations§
source§impl<ReqArgs: Debug, OptArgs: Debug, RestArgs: Debug, Meta: Debug> Debug for ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
impl<ReqArgs: Debug, OptArgs: Debug, RestArgs: Debug, Meta: Debug> Debug for ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
source§impl<ReqArgs, OptArgs, RestArgs, Meta> ParseAttrTrait for ParseArgs<Marker<ReqArgs>, Marker<OptArgs>, Marker<RestArgs>, Meta>where
ReqArgs: ParseRequiredArgs,
OptArgs: ParseOptionalArgs,
RestArgs: ParseRestArgs,
Meta: ParseMeta,
impl<ReqArgs, OptArgs, RestArgs, Meta> ParseAttrTrait for ParseArgs<Marker<ReqArgs>, Marker<OptArgs>, Marker<RestArgs>, Meta>where
ReqArgs: ParseRequiredArgs,
OptArgs: ParseOptionalArgs,
RestArgs: ParseRestArgs,
Meta: ParseMeta,
Auto Trait Implementations§
impl<ReqArgs, OptArgs, RestArgs, Meta> Freeze for ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
impl<ReqArgs, OptArgs, RestArgs, Meta> RefUnwindSafe for ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
impl<ReqArgs, OptArgs, RestArgs, Meta> Send for ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
impl<ReqArgs, OptArgs, RestArgs, Meta> Sync for ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
impl<ReqArgs, OptArgs, RestArgs, Meta> Unpin for ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
impl<ReqArgs, OptArgs, RestArgs, Meta> UnwindSafe for ParseArgs<ReqArgs, OptArgs, RestArgs, Meta>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more