Shared References when Folding with a Row or Column? #1382
-
Is there an existing issue for this?
Is this issue related to iced?
What happened?Hi, I'm trying to create a layout kind of like the Pinterest "masonry" layout. I have a 2D vec of image thumbnails I'm using fold to iterate over, and running into issues around shared references. let row = row().width(Length::Fill).height(Length::Fill);
let row = image_grid.iter().fold(row, |r, images| {
let column = column().spacing(row_spacing).width(col_width);
let column = images.iter().fold(column, |c, path| {
let el = self.publish_thumbs.get(path).as_ref().map(|thumb| {
image(Handle::from_pixels(
thumb.val().metadata.width_px,
thumb.val().metadata.height_px,
thumb.val().image.to_vec(),
))
});
if let Some(el) = el {
c.push(el);
}
c
});
r.push(column);
r
});
let scrollable = scrollable(row);
What is the expected behavior?I was hoping to not need to use smart pointers, but I may need to. It's just hard to move things out of the smart pointers after using them. Version0.4 Operative SystemLinux Do you have any log output?No response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
It'd be really nice if there was an impl for let row = row(image_grid.iter().map(|images| {
column(images.iter().filter_map(|path| {
self.publish_thumbs.get(path).as_ref().map(|thumb| {
image(Handle::from_pixels(
thumb.val().metadata.width_px,
thumb.val().metadata.height_px,
thumb.val().image.to_vec(),
))
})
}))
.spacing(row_spacing)
.width(col_width)
}))
.width(Length::Fill)
.height(Length::Fill); |
Beta Was this translation helpful? Give feedback.
-
// ...
if let Some(el) = el {
c.push(el)
} else {
c
}
});
r.push(column)
}); |
Beta Was this translation helpful? Give feedback.
push
takesself
and returnsSelf
, so you can just write: