I have a vec of n Elements I've built from server JSON. I'd like to push these all into a Column. I tried to do a for loop and push onto an existing Column, but I think because push captures self not &self I can't do this because of the borrow checker (I'm new to Rust, please correct me).
I have a local fork with a new instantiation method. It seems to hold true to the spirit of immutability.
/// Creates an full [`Column`].
///
/// [`Column`]: struct.Column.html
pub fn new_with_children(
children: Vec<Element<'a, Message, Renderer>>,
) -> Self {
Column {
spacing: 0,
padding: 0,
width: Length::Shrink,
height: Length::Shrink,
max_width: u32::MAX,
max_height: u32::MAX,
align_items: Align::Start,
children,
}
}
Is that a welcome PR, or is there a better way?
I do something like what you want with Airshipper, check out https://github.com/Songtronix/Airshipper/blob/master/client/src/gui/mod.rs
You probably are interested in the news part but sadly can't explain more right now but if needed I can sure help you tomorrow.
@rowungiles You should be able to fold an iterator. The todos example does this to generate the list of tasks:
That said, I agree Column::with_children and Row::with_children would be nice additions. By all means, feel free to open a PR!
Super, I'll do that. Thank you.
And yes, of course you were both correct. fold did exactly what I wanted.
Closed by #220. Thank you! :tada: