pub trait ArgumentSetMethods: Copy + Sized {
type Each: Sized;
type Field: Sized;
// Required methods
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>;
fn debug_core(self) -> &'static str;
// Provided methods
fn argument_set_debug(self) -> impl Debug { ... }
fn check_argument_value_parseable(self)
where Self::Each: ItemArgumentParseable { ... }
}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.
Sourcefn debug_core(self) -> &'static str
fn debug_core(self) -> &'static str
Multiplicity representation for #[deftly(netdoc(debug))] output, core
Should generally be in a form like Vec<_>.
See ItemSetMethods::debug_core and ArgumentSetMethods::argument_set_debug.
Provided Methods§
Sourcefn argument_set_debug(self) -> impl Debug
fn argument_set_debug(self) -> impl Debug
Multiplicity representation for #[deftly(netdoc(debug))] output
See ItemSetMethods::item_set_debug and ArgumentSetMethods::debug_core.
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.