gtk-rs-core
gtk-rs-core copied to clipboard
Use `T: AsRef<str>, &[T]` instead of `&[&str]` in various APIs
Much nicer to use if your strings are actual String.
Same thing applies for other &[&T] we might have in API somewhere as with AsRef both &[T] and &[&T] would be possible to pass in (and other AsRef impls of course).
@pbor btw, this is why I mentioned that yesterday
Does this issue also refers to all APIs that accept &str as argument as well? I see that those would also benefit from similar change.
Do you have an example usage for that where it makes things better? For &str it's not really much of a problem as you can simply .as_str() / .as_ref() in your function call. For slices it's more difficult because that would require re-allocating the whole slice into a temporary Vec or so.
@sdroege I think you're right, the &str argument is pretty straight forward to use with String. Maybe not worth the change after all.
Yeah, I had troubles trying to use gio::Settings, set_strv while trying to push a single value into the setting.
At this point this should probably rather make use of impl IntoStrV
This would be covered by https://github.com/gtk-rs/gtk-rs-core/issues/884 now.