'Different text new unique button state
I am running into this error code cannot borrow bars.upload as mutable more than once at a time bars.upload was mutably borrowed here in the previous iteration of the looprustcE0499
Here is the code
let scrollable_row = Row::with_children(
self.bars
.iter_mut()
.enumerate()
.map(|(i, bars)| {
let mut scrollable =
Scrollable::new(&mut bars.scrollable)
.padding(10)
.spacing(10)
.width(Length::Fill)
.height(Length::Fill)
.on_scroll(move |offset| {
Message::Scrolled(i, offset)
})
.style(self.theme)
.push(Text::new(bars.title))
.push(Text::new(bars.desc));
for j in 0..bars.content.len() {
scrollable = scrollable
.push(
iced::Button::new(
&mut bars.upload,
Text::new(bars.content[j].clone()))
);
}
Is there a way to link them together, I would like the button states to be different but in a for loop. Is there a way around this like maybe creating a new button state for each or all togther avoiding button states. What i am trying to do is create mutiple buttons without knowing how many buttons i need. I do not mind using a pick list or a radio button if it is possible. Btw all i need is the name that is clicked (bars.upload) which i pass into the message state TLDR; make mutiple unique buttons in for loop
Solution 1:[1]
Please have a look https://github.com/iced-rs/iced/blob/master/examples/todos/src/main.rs which implements a saved state in the form of json and makes use of dynamic size buttons. This would be too long for this stackoverflow answer but it is possible and there are no limitations
Solution 2:[2]
Solution is overflow-wrap: break-word;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jonathan Coletti |
| Solution 2 | Mark Kostevych |
