macro_rules! forward_from_iterator {
(<$($generic:ident),+> in $($rest:tt)+) => { ... };
(<const $($rest:tt)+) => { ... };
(<$generic:ident, $($rest:tt)+) => { ... };
(@impl [$($generic:tt)+] $this:ty => $inner:ty $(,)?) => { ... };
($this:ty => $field:tt : $inner:ty $(,)?) => { ... };
($this:ty => $inner:ty $(,)?) => { ... };
(@impl [$($generic:tt)*] $this:ty => $field:tt : $inner:ty $(,)?) => { ... };
}Expand description
Implement FromIterator for a single-field wrapper.
Accept any item type supported by the inner collection’s FromIterator
implementation. The inner type does not need to implement IntoIterator.
Emitted code supports no_std.
Declare type and const parameters before in.
§Examples
struct Items<T>(Vec<T>);
impl_more::forward_from_iterator!(<T> in Items<T> => Vec<T>);
let items = (1..4).collect::<Items<_>>();
assert_eq!(items.0, vec![1, 2, 3]);struct Text { value: String }
impl_more::forward_from_iterator!(Text => value: String);
let text = ["hello", " world"].iter().copied().collect::<Text>();
assert_eq!(text.value, "hello world");