gtk-rs / gtk-rs-core

Rust bindings for GNOME libraries
https://gtk-rs.org/gtk-rs-core
MIT License
286 stars 114 forks source link

Functions taking `&[T]` might be more generic with `impl IntoIterator<Item = T>` #274

Open sdroege opened 3 years ago

sdroege commented 3 years ago

We have various functions that take a slice as argument currently. Most of them would convert the slice into a Vec<*mut _> or similar before passing to C functions. As such it would make sense to directly allow using anything that can be iterated over.

For functions taking some plain type T this is straightforward (e.g. &[&str] would become impl IntoIterator<Item = &str>), for functions taking a &dyn T (e.g. &[&dyn ToValue]) this is a bit problematic because of https://github.com/rust-lang/rust/issues/89222.

Because of that I would suggest to only do it for slices that are not containing trait objects for now, unless someone knows a way around that.

@bilelmoussaoui @GuillaumeGomez Any opinions?

GuillaumeGomez commented 3 years ago

If the compiler errors are acceptable, then why not.