FromFormMultiple

Trait FromFormMultiple 

Source
pub trait FromFormMultiple<'f>: Sized {
    type Item;

    // Required methods
    fn push(&mut self, item: Self::Item);
    fn default() -> Self;
}
Available on crate feature from_form only.
Expand description

A trait for types that can be created from a form.

This is used exclusively for arrays. It is expected that you use the #[derive(FromForm)] attribute on your type. This will generate a from_form method that correctly parses the types from the form. This handles types that expect multiple key-value pairs with the same keys, such as for arrays. As such, this trait is automatically implemented for any type T such that T: Default + Extend<V> + IntoIterator<Item = V>. This should cover all cases, and you should not need to implement (or use) this.

Required Associated Types§

Source

type Item

The item type that is being collected into Self.

Required Methods§

Source

fn push(&mut self, item: Self::Item)

Given for a key-value pair, adds the value to self. This also has the side effect of parsing the item into the correct type (using its corresponding FromFormValue implementation).

Source

fn default() -> Self

Return the default (empty) collection of Self. This should just be Default::default.

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.

Implementors§

Source§

impl<'f, V, T> FromFormMultiple<'f> for T
where T: Default + Extend<V> + IntoIterator<Item = V>,

Source§

type Item = V