PistonDevelopers / conrod

An easy-to-use, 2D GUI library written entirely in Rust.
Other
3.35k stars 297 forks source link

widget::id::List` is not an iterator also widget::id::ListWalk is not an iterator #1396

Closed MrGibus closed 4 years ago

MrGibus commented 4 years ago

Trying to create ids for a variable number of items for the circles 7guis benchmark here I've come across this example and this issue. Both indicate using list ids. But its throwing and error telling me that it's not an iterator.

ids.toggles.resize(5, &mut ui.widget_id_generator()); for id in ids.toggles { widget::Toggle::new(true).set(id, ui); }

I've also tried

ids.toggles.resize(5, &mut ui.widget_id_generator()); for id in ids.toggles.walk() { widget::Toggle::new(true).set(id, ui); }

Is this not meant to be an iterator?

alvinhochun commented 4 years ago

It is probably outdated. The widget id lists are conrod_core::widget::id::List, which derefs to a slice, so you would probably need:

for id in ids.toggles.iter() {
    // ...
}
MrGibus commented 4 years ago

Thank you. using .iter() and .set(*id, ui), works as i'd expect.