pub trait ArgumentSetMethods: Copy + Sized {
type Each: Sized;
type Field: Sized;
// Required method
fn parse_with<P>(
self,
args: &mut ArgumentStream<'_>,
parser: P,
) -> Result<Self::Field, AE>
where P: for<'s> Fn(&mut ArgumentStream<'s>) -> Result<Self::Each, AE>;
// Provided method
fn check_argument_value_parseable(self)
where Self::Each: ItemArgumentParseable { ... }
}Available on crate feature
parse2 only.Expand description
Method for handling some multiplicity of Arguments
For use by macros.
See the module-level docs, and
Field type in ItemValueParseable.
§Example
The code in the (derive) macro output is roughly like this:
use tor_netdoc::parse2::multiplicity::{MultiplicitySelector, ArgumentSetMethods as _};
use tor_netdoc::parse2::{ItemArgumentParseable, ItemStream, ParseInput};
let doc = "intro-item 12 66\n";
let input = ParseInput::new(doc, "<literal>");
let mut items = ItemStream::new(&input).unwrap();
let mut item = items.next().unwrap().unwrap();
let args = MultiplicitySelector::<Vec<i32>>::default()
.parse_with(item.args_mut(), ItemArgumentParseable::from_args)
.unwrap();
assert_eq!(args, [12, 66]);Required Associated Types§
Required Methods§
Sourcefn parse_with<P>(
self,
args: &mut ArgumentStream<'_>,
parser: P,
) -> Result<Self::Field, AE>
fn parse_with<P>( self, args: &mut ArgumentStream<'_>, parser: P, ) -> Result<Self::Field, AE>
Parse zero or more argument(s) into Self::Field.
Provided Methods§
Sourcefn check_argument_value_parseable(self)where
Self::Each: ItemArgumentParseable,
fn check_argument_value_parseable(self)where
Self::Each: ItemArgumentParseable,
Check that the element type is an Argument
For providing better error messages when struct fields don’t implement the right trait.
See derive.rs, and search for this method name.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.