gtk-rs-core icon indicating copy to clipboard operation
gtk-rs-core copied to clipboard

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

Open sdroege opened this issue 2 years ago • 1 comments

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?

sdroege avatar Sep 25 '21 09:09 sdroege

If the compiler errors are acceptable, then why not.

GuillaumeGomez avatar Sep 25 '21 14:09 GuillaumeGomez