macro_rules! forward_extend {
(<$($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 Extend by forwarding to a field.
Accept any item type supported by the inner collection’s Extend
implementation. Emitted code supports no_std.
Declare type and const parameters before in.
§Examples
struct Items<T>(Vec<T>);
impl_more::forward_extend!(<T> in Items<T> => Vec<T>);
let mut items = Items(vec![1]);
items.extend([2, 3]);
assert_eq!(items.0, vec![1, 2, 3]);struct Text { value: String }
impl_more::forward_extend!(Text => value: String);
let mut text = Text { value: String::new() };
text.extend(["hello", " world"]);
assert_eq!(text.value, "hello world");