mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-09-02 01:43:49 +00:00
Don't use impl IntoIterator<Item = impl SomeTrait>
Instead use a generic type parameter for the item. This allows calling e.g. gst::Array:🆕:<&str>([]) as a type annotation is necessary in such cases. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1691>
This commit is contained in:
parent
757352c6cc
commit
5051f522b7
11 changed files with 168 additions and 107 deletions
|
@ -91,27 +91,27 @@ impl AudioCapsBuilder<gst::caps::NoFeature> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn features(
|
||||
pub fn features<S: IntoGStr>(
|
||||
self,
|
||||
features: impl IntoIterator<Item = impl IntoGStr>,
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> AudioCapsBuilder<gst::caps::HasFeatures> {
|
||||
AudioCapsBuilder {
|
||||
builder: self.builder.features(features),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn features_from_statics(
|
||||
pub fn features_from_statics<S: AsRef<glib::GStr> + 'static>(
|
||||
self,
|
||||
features: impl IntoIterator<Item = impl AsRef<glib::GStr> + 'static>,
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> AudioCapsBuilder<gst::caps::HasFeatures> {
|
||||
AudioCapsBuilder {
|
||||
builder: self.builder.features_from_statics(features),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn features_from_ids(
|
||||
pub fn features_from_ids<S: AsRef<IdStr>>(
|
||||
self,
|
||||
features: impl IntoIterator<Item = impl AsRef<IdStr>>,
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> AudioCapsBuilder<gst::caps::HasFeatures> {
|
||||
AudioCapsBuilder {
|
||||
builder: self.builder.features_from_ids(features),
|
||||
|
|
|
@ -24,7 +24,7 @@ impl RTSPToken {
|
|||
}
|
||||
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn from_iter(iter: impl IntoIterator<Item = (impl IntoGStr, SendValue)>) -> RTSPToken {
|
||||
pub fn from_iter<S: IntoGStr>(iter: impl IntoIterator<Item = (S, SendValue)>) -> RTSPToken {
|
||||
skip_assert_initialized!();
|
||||
let mut token = RTSPToken::new_empty();
|
||||
|
||||
|
|
|
@ -73,27 +73,27 @@ impl VideoCapsBuilder<gst::caps::NoFeature> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn features(
|
||||
pub fn features<S: IntoGStr>(
|
||||
self,
|
||||
features: impl IntoIterator<Item = impl IntoGStr>,
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> VideoCapsBuilder<gst::caps::HasFeatures> {
|
||||
VideoCapsBuilder {
|
||||
builder: self.builder.features(features),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn features_from_statics(
|
||||
pub fn features_from_statics<S: AsRef<glib::GStr> + 'static>(
|
||||
self,
|
||||
features: impl IntoIterator<Item = impl AsRef<glib::GStr> + 'static>,
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> VideoCapsBuilder<gst::caps::HasFeatures> {
|
||||
VideoCapsBuilder {
|
||||
builder: self.builder.features_from_statics(features),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn features_from_ids(
|
||||
pub fn features_from_ids<S: AsRef<IdStr>>(
|
||||
self,
|
||||
features: impl IntoIterator<Item = impl AsRef<IdStr>>,
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> VideoCapsBuilder<gst::caps::HasFeatures> {
|
||||
VideoCapsBuilder {
|
||||
builder: self.builder.features_from_ids(features),
|
||||
|
|
|
@ -47,9 +47,9 @@ impl Bin {
|
|||
|
||||
pub trait GstBinExtManual: IsA<Bin> + 'static {
|
||||
#[doc(alias = "gst_bin_add_many")]
|
||||
fn add_many(
|
||||
fn add_many<E: AsRef<Element>>(
|
||||
&self,
|
||||
elements: impl IntoIterator<Item = impl AsRef<Element>>,
|
||||
elements: impl IntoIterator<Item = E>,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
for e in elements {
|
||||
unsafe {
|
||||
|
@ -64,9 +64,9 @@ pub trait GstBinExtManual: IsA<Bin> + 'static {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_bin_remove_many")]
|
||||
fn remove_many(
|
||||
fn remove_many<E: AsRef<Element>>(
|
||||
&self,
|
||||
elements: impl IntoIterator<Item = impl AsRef<Element>>,
|
||||
elements: impl IntoIterator<Item = E>,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
for e in elements {
|
||||
unsafe {
|
||||
|
|
|
@ -473,10 +473,13 @@ impl CapsRef {
|
|||
///
|
||||
/// Overrides any default or previously defined value for `name`.
|
||||
#[inline]
|
||||
pub fn set_from_iter<V: ValueType + ToSendValue + FromIterator<SendValue> + Sync>(
|
||||
pub fn set_from_iter<
|
||||
V: ValueType + ToSendValue + FromIterator<SendValue> + Sync,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl IntoGStr,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.set(name, V::from_iter(iter));
|
||||
|
@ -489,10 +492,11 @@ impl CapsRef {
|
|||
#[inline]
|
||||
pub fn set_with_static_from_iter<
|
||||
V: ValueType + ToSendValue + FromIterator<SendValue> + Sync,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl AsRef<GStr> + 'static,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.set_with_static(name, V::from_iter(iter));
|
||||
|
@ -503,10 +507,13 @@ impl CapsRef {
|
|||
///
|
||||
/// Overrides any default or previously defined value for `name`.
|
||||
#[inline]
|
||||
pub fn set_with_id_from_iter<V: ValueType + ToSendValue + FromIterator<SendValue> + Sync>(
|
||||
pub fn set_with_id_from_iter<
|
||||
V: ValueType + ToSendValue + FromIterator<SendValue> + Sync,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl AsRef<IdStr>,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.set_with_id(name, V::from_iter(iter));
|
||||
|
@ -518,10 +525,13 @@ impl CapsRef {
|
|||
///
|
||||
/// This has no effect if `iter` is empty, i.e. previous value for `name` is unchanged.
|
||||
#[inline]
|
||||
pub fn set_if_not_empty<V: ValueType + ToSendValue + FromIterator<SendValue> + Sync>(
|
||||
pub fn set_if_not_empty<
|
||||
V: ValueType + ToSendValue + FromIterator<SendValue> + Sync,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl IntoGStr,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -538,10 +548,11 @@ impl CapsRef {
|
|||
#[inline]
|
||||
pub fn set_with_static_if_not_empty<
|
||||
V: ValueType + ToSendValue + FromIterator<SendValue> + Sync,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl AsRef<GStr> + 'static,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -556,10 +567,13 @@ impl CapsRef {
|
|||
///
|
||||
/// This has no effect if `iter` is empty, i.e. previous value for `name` is unchanged.
|
||||
#[inline]
|
||||
pub fn set_with_id_if_not_empty<V: ValueType + ToSendValue + FromIterator<SendValue> + Sync>(
|
||||
pub fn set_with_id_if_not_empty<
|
||||
V: ValueType + ToSendValue + FromIterator<SendValue> + Sync,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl AsRef<IdStr>,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -1293,9 +1307,9 @@ impl Builder<NoFeature> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn features(
|
||||
pub fn features<S: IntoGStr>(
|
||||
self,
|
||||
features: impl IntoIterator<Item = impl IntoGStr>,
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> Builder<HasFeatures> {
|
||||
Builder {
|
||||
s: self.s,
|
||||
|
@ -1304,9 +1318,9 @@ impl Builder<NoFeature> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn features_from_statics(
|
||||
pub fn features_from_statics<S: AsRef<GStr> + 'static>(
|
||||
self,
|
||||
features: impl IntoIterator<Item = impl AsRef<GStr> + 'static>,
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> Builder<HasFeatures> {
|
||||
Builder {
|
||||
s: self.s,
|
||||
|
@ -1315,9 +1329,9 @@ impl Builder<NoFeature> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn features_from_ids(
|
||||
pub fn features_from_ids<S: AsRef<IdStr>>(
|
||||
self,
|
||||
features: impl IntoIterator<Item = impl AsRef<IdStr>>,
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> Builder<HasFeatures> {
|
||||
Builder {
|
||||
s: self.s,
|
||||
|
|
|
@ -22,7 +22,7 @@ unsafe impl Sync for CapsFeatures {}
|
|||
|
||||
impl CapsFeatures {
|
||||
#[doc(alias = "gst_caps_features_new")]
|
||||
pub fn new(features: impl IntoIterator<Item = impl IntoGStr>) -> Self {
|
||||
pub fn new<S: IntoGStr>(features: impl IntoIterator<Item = S>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let mut f = Self::new_empty();
|
||||
|
||||
|
@ -34,8 +34,8 @@ impl CapsFeatures {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_caps_features_new_static_str")]
|
||||
pub fn new_from_static(
|
||||
features: impl IntoIterator<Item = impl AsRef<glib::GStr> + 'static>,
|
||||
pub fn new_from_static<S: AsRef<glib::GStr> + 'static>(
|
||||
features: impl IntoIterator<Item = S>,
|
||||
) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let mut f = Self::new_empty();
|
||||
|
@ -48,7 +48,7 @@ impl CapsFeatures {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_caps_features_new_id_str")]
|
||||
pub fn new_from_id(features: impl IntoIterator<Item = impl AsRef<IdStr>>) -> Self {
|
||||
pub fn new_from_id<S: AsRef<IdStr>>(features: impl IntoIterator<Item = S>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let mut f = Self::new_empty();
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ use crate::{
|
|||
|
||||
impl Element {
|
||||
#[doc(alias = "gst_element_link_many")]
|
||||
pub fn link_many(
|
||||
elements: impl IntoIterator<Item = impl AsRef<Element> + Clone>,
|
||||
pub fn link_many<E: AsRef<Element> + Clone>(
|
||||
elements: impl IntoIterator<Item = E>,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
for (src, dest) in elements.into_iter().tuple_windows() {
|
||||
|
@ -40,7 +40,7 @@ impl Element {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_element_unlink_many")]
|
||||
pub fn unlink_many(elements: impl IntoIterator<Item = impl AsRef<Element> + Clone>) {
|
||||
pub fn unlink_many<E: AsRef<Element> + Clone>(elements: impl IntoIterator<Item = E>) {
|
||||
skip_assert_initialized!();
|
||||
for (src, dest) in elements.into_iter().tuple_windows() {
|
||||
unsafe {
|
||||
|
|
|
@ -4111,19 +4111,22 @@ impl<'a> PropertyNotifyBuilder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn value_from_iter<V: ValueType + ToSendValue + FromIterator<SendValue>>(
|
||||
pub fn value_from_iter<V: ValueType + ToSendValue + FromIterator<SendValue>, I: ToSendValue>(
|
||||
self,
|
||||
name: &'a str,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.other_field(name, V::from_iter(iter))
|
||||
}
|
||||
|
||||
pub fn value_field_if_not_empty<V: ValueType + ToSendValue + FromIterator<SendValue>>(
|
||||
pub fn value_field_if_not_empty<
|
||||
V: ValueType + ToSendValue + FromIterator<SendValue>,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: &'a str,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -4181,9 +4184,9 @@ impl<'a> StreamsSelectedBuilder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn streams(
|
||||
pub fn streams<S: std::borrow::Borrow<crate::Stream>>(
|
||||
self,
|
||||
streams: impl IntoIterator<Item = impl std::borrow::Borrow<crate::Stream>>,
|
||||
streams: impl IntoIterator<Item = S>,
|
||||
) -> Self {
|
||||
Self {
|
||||
streams: streams
|
||||
|
@ -4194,9 +4197,9 @@ impl<'a> StreamsSelectedBuilder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn streams_if(
|
||||
pub fn streams_if<S: std::borrow::Borrow<crate::Stream>>(
|
||||
self,
|
||||
streams: impl IntoIterator<Item = impl std::borrow::Borrow<crate::Stream>>,
|
||||
streams: impl IntoIterator<Item = S>,
|
||||
predicate: bool,
|
||||
) -> Self {
|
||||
if predicate {
|
||||
|
@ -4206,9 +4209,9 @@ impl<'a> StreamsSelectedBuilder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn streams_if_some(
|
||||
pub fn streams_if_some<S: std::borrow::Borrow<crate::Stream>>(
|
||||
self,
|
||||
streams: Option<impl IntoIterator<Item = impl std::borrow::Borrow<crate::Stream>>>,
|
||||
streams: Option<impl IntoIterator<Item = S>>,
|
||||
) -> Self {
|
||||
if let Some(streams) = streams {
|
||||
self.streams(streams)
|
||||
|
@ -4217,9 +4220,9 @@ impl<'a> StreamsSelectedBuilder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn streams_if_not_empty(
|
||||
pub fn streams_if_not_empty<S: std::borrow::Borrow<crate::Stream>>(
|
||||
self,
|
||||
streams: impl IntoIterator<Item = impl std::borrow::Borrow<crate::Stream>>,
|
||||
streams: impl IntoIterator<Item = S>,
|
||||
) -> Self {
|
||||
let mut streams = streams.into_iter().peekable();
|
||||
if streams.peek().is_some() {
|
||||
|
|
|
@ -120,9 +120,9 @@ impl Structure {
|
|||
}
|
||||
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn from_iter(
|
||||
pub fn from_iter<S: IntoGStr>(
|
||||
name: impl IntoGStr,
|
||||
iter: impl IntoIterator<Item = (impl IntoGStr, SendValue)>,
|
||||
iter: impl IntoIterator<Item = (S, SendValue)>,
|
||||
) -> Structure {
|
||||
skip_assert_initialized!();
|
||||
let mut structure = Structure::new_empty(name);
|
||||
|
@ -134,9 +134,9 @@ impl Structure {
|
|||
}
|
||||
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn from_iter_with_static(
|
||||
pub fn from_iter_with_static<S: AsRef<GStr> + 'static>(
|
||||
name: impl AsRef<GStr> + 'static,
|
||||
iter: impl IntoIterator<Item = (impl AsRef<GStr> + 'static, SendValue)>,
|
||||
iter: impl IntoIterator<Item = (S, SendValue)>,
|
||||
) -> Structure {
|
||||
skip_assert_initialized!();
|
||||
let mut structure = Structure::new_empty_from_static(name);
|
||||
|
@ -148,9 +148,9 @@ impl Structure {
|
|||
}
|
||||
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn from_iter_with_id(
|
||||
pub fn from_iter_with_id<S: AsRef<IdStr>>(
|
||||
name: impl AsRef<IdStr>,
|
||||
iter: impl IntoIterator<Item = (impl AsRef<IdStr>, SendValue)>,
|
||||
iter: impl IntoIterator<Item = (S, SendValue)>,
|
||||
) -> Structure {
|
||||
skip_assert_initialized!();
|
||||
let mut structure = Structure::new_empty_from_id(name);
|
||||
|
@ -789,10 +789,13 @@ impl StructureRef {
|
|||
///
|
||||
/// Overrides any default or previously defined value for `name`.
|
||||
#[inline]
|
||||
pub fn set_from_iter<V: ValueType + Into<Value> + FromIterator<SendValue> + Send>(
|
||||
pub fn set_from_iter<
|
||||
V: ValueType + Into<Value> + FromIterator<SendValue> + Send,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl IntoGStr,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.set(name, V::from_iter(iter));
|
||||
|
@ -805,10 +808,11 @@ impl StructureRef {
|
|||
#[inline]
|
||||
pub fn set_with_static_from_iter<
|
||||
V: ValueType + Into<Value> + FromIterator<SendValue> + Send,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl AsRef<GStr> + 'static,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.set_with_static(name, V::from_iter(iter));
|
||||
|
@ -819,10 +823,13 @@ impl StructureRef {
|
|||
///
|
||||
/// Overrides any default or previously defined value for `name`.
|
||||
#[inline]
|
||||
pub fn set_with_id_from_iter<V: ValueType + Into<Value> + FromIterator<SendValue> + Send>(
|
||||
pub fn set_with_id_from_iter<
|
||||
V: ValueType + Into<Value> + FromIterator<SendValue> + Send,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl AsRef<IdStr>,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.set_with_id(name, V::from_iter(iter));
|
||||
|
@ -834,10 +841,13 @@ impl StructureRef {
|
|||
///
|
||||
/// This has no effect if `iter` is empty, i.e. previous value for `name` is unchanged.
|
||||
#[inline]
|
||||
pub fn set_if_not_empty<V: ValueType + Into<Value> + FromIterator<SendValue> + Send>(
|
||||
pub fn set_if_not_empty<
|
||||
V: ValueType + Into<Value> + FromIterator<SendValue> + Send,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl IntoGStr,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -854,10 +864,11 @@ impl StructureRef {
|
|||
#[inline]
|
||||
pub fn set_with_static_if_not_empty<
|
||||
V: ValueType + Into<Value> + FromIterator<SendValue> + Send,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl AsRef<GStr> + 'static,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -872,10 +883,13 @@ impl StructureRef {
|
|||
///
|
||||
/// This has no effect if `iter` is empty, i.e. previous value for `name` is unchanged.
|
||||
#[inline]
|
||||
pub fn set_with_id_if_not_empty<V: ValueType + Into<Value> + FromIterator<SendValue> + Send>(
|
||||
pub fn set_with_id_if_not_empty<
|
||||
V: ValueType + Into<Value> + FromIterator<SendValue> + Send,
|
||||
I: ToSendValue,
|
||||
>(
|
||||
&mut self,
|
||||
name: impl AsRef<IdStr>,
|
||||
iter: impl IntoIterator<Item = impl ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -1242,7 +1256,7 @@ impl StructureRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_structure_remove_fields")]
|
||||
pub fn remove_fields(&mut self, fields: impl IntoIterator<Item = impl IntoGStr>) {
|
||||
pub fn remove_fields<S: IntoGStr>(&mut self, fields: impl IntoIterator<Item = S>) {
|
||||
for f in fields.into_iter() {
|
||||
self.remove_field(f)
|
||||
}
|
||||
|
@ -1262,7 +1276,7 @@ impl StructureRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_structure_id_str_remove_fields")]
|
||||
pub fn remove_field_by_ids(&mut self, fields: impl IntoIterator<Item = impl AsRef<IdStr>>) {
|
||||
pub fn remove_field_by_ids<S: AsRef<IdStr>>(&mut self, fields: impl IntoIterator<Item = S>) {
|
||||
for f in fields.into_iter() {
|
||||
self.remove_field_by_id(f)
|
||||
}
|
||||
|
@ -2314,9 +2328,9 @@ mod tests {
|
|||
static SLIST: &GStr = gstr!("slist");
|
||||
let ilist = idstr!("ilist");
|
||||
let s = Structure::builder("test")
|
||||
.field_from_iter::<crate::Array>("array", [&1, &2, &3])
|
||||
.field_with_static_from_iter::<crate::List>(SLIST, [&4, &5, &6])
|
||||
.field_with_id_from_iter::<crate::List>(&ilist, [&7, &8, &9])
|
||||
.field_from_iter::<crate::Array, i32>("array", [1, 2, 3])
|
||||
.field_with_static_from_iter::<crate::List, i32>(SLIST, [4, 5, 6])
|
||||
.field_with_id_from_iter::<crate::List, i32>(&ilist, [7, 8, 9])
|
||||
.build();
|
||||
assert!(s
|
||||
.get::<crate::Array>("array")
|
||||
|
@ -2339,9 +2353,9 @@ mod tests {
|
|||
|
||||
let array = Vec::<i32>::new();
|
||||
let s = Structure::builder("test")
|
||||
.field_from_iter::<crate::Array>("array", &array)
|
||||
.field_with_static_from_iter::<crate::List>(SLIST, &array)
|
||||
.field_with_id_from_iter::<crate::List>(&ilist, &array)
|
||||
.field_from_iter::<crate::Array, _>("array", &array)
|
||||
.field_with_static_from_iter::<crate::List, _>(SLIST, &array)
|
||||
.field_with_id_from_iter::<crate::List, _>(&ilist, &array)
|
||||
.build();
|
||||
assert!(s.get::<crate::Array>("array").unwrap().as_ref().is_empty());
|
||||
assert!(s.get::<crate::List>(SLIST).unwrap().as_ref().is_empty());
|
||||
|
@ -2359,9 +2373,9 @@ mod tests {
|
|||
static SLIST: &GStr = gstr!("slist");
|
||||
let ilist = idstr!("ilist");
|
||||
let s = Structure::builder_from_id(idstr!("test"))
|
||||
.field_if_not_empty::<crate::Array>("array", [&1, &2, &3])
|
||||
.field_with_static_if_not_empty::<crate::List>(SLIST, [&4, &5, &6])
|
||||
.field_with_id_if_not_empty::<crate::List>(&ilist, [&7, &8, &9])
|
||||
.field_if_not_empty::<crate::Array, i32>("array", [1, 2, 3])
|
||||
.field_with_static_if_not_empty::<crate::List, i32>(SLIST, [4, 5, 6])
|
||||
.field_with_id_if_not_empty::<crate::List, i32>(&ilist, [7, 8, 9])
|
||||
.build();
|
||||
assert!(s
|
||||
.get::<crate::Array>("array")
|
||||
|
@ -2384,9 +2398,9 @@ mod tests {
|
|||
|
||||
let array = Vec::<i32>::new();
|
||||
let s = Structure::builder("test")
|
||||
.field_if_not_empty::<crate::Array>("array", &array)
|
||||
.field_with_static_if_not_empty::<crate::List>(SLIST, &array)
|
||||
.field_with_id_if_not_empty::<crate::List>(ilist, &array)
|
||||
.field_if_not_empty::<crate::Array, _>("array", &array)
|
||||
.field_with_static_if_not_empty::<crate::List, _>(SLIST, &array)
|
||||
.field_with_id_if_not_empty::<crate::List, _>(ilist, &array)
|
||||
.build();
|
||||
assert!(!s.has_field("array"));
|
||||
assert!(!s.has_field("slist"));
|
||||
|
|
|
@ -846,7 +846,7 @@ mod tests {
|
|||
.eq(["default0", "default1"]));
|
||||
|
||||
let elem = crate::ElementFactory::make("testelement")
|
||||
.property_from_iter::<crate::Array>("array", ["value0", "value1"])
|
||||
.property_from_iter::<crate::Array, _>("array", ["value0", "value1"])
|
||||
.build()
|
||||
.unwrap();
|
||||
assert!(elem
|
||||
|
@ -857,7 +857,7 @@ mod tests {
|
|||
|
||||
let array = Vec::<String>::new();
|
||||
let elem = crate::ElementFactory::make("testelement")
|
||||
.property_if_not_empty::<crate::Array>("array", &array)
|
||||
.property_if_not_empty::<crate::Array, _>("array", &array)
|
||||
.build()
|
||||
.unwrap();
|
||||
assert!(elem
|
||||
|
@ -867,7 +867,7 @@ mod tests {
|
|||
.eq(["default0", "default1"]));
|
||||
|
||||
let elem = crate::ElementFactory::make("testelement")
|
||||
.property_if_not_empty::<crate::Array>("array", ["value0", "value1"])
|
||||
.property_if_not_empty::<crate::Array, _>("array", ["value0", "value1"])
|
||||
.build()
|
||||
.unwrap();
|
||||
assert!(elem
|
||||
|
|
|
@ -829,7 +829,7 @@ impl fmt::Debug for Array {
|
|||
}
|
||||
|
||||
impl Array {
|
||||
pub fn new(values: impl IntoIterator<Item = impl Into<glib::Value> + Send>) -> Self {
|
||||
pub fn new<T: Into<glib::Value> + Send>(values: impl IntoIterator<Item = T>) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe {
|
||||
|
@ -1056,7 +1056,7 @@ impl fmt::Debug for List {
|
|||
}
|
||||
|
||||
impl List {
|
||||
pub fn new(values: impl IntoIterator<Item = impl Into<glib::Value> + Send>) -> Self {
|
||||
pub fn new<T: Into<glib::Value> + Send>(values: impl IntoIterator<Item = T>) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe {
|
||||
|
@ -1575,10 +1575,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// Overrides any default or previously defined value for `name`.
|
||||
#[inline]
|
||||
pub fn field_from_iter<V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send>(
|
||||
pub fn field_from_iter<
|
||||
V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: impl $crate::glib::IntoGStr,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.field(name, V::from_iter(iter))
|
||||
|
@ -1589,10 +1592,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// Overrides any default or previously defined value for `name`.
|
||||
#[inline]
|
||||
pub fn field_with_static_from_iter<V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send>(
|
||||
pub fn field_with_static_from_iter<
|
||||
V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: impl AsRef<$crate::glib::GStr> + 'static,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.field_with_static(name, V::from_iter(iter))
|
||||
|
@ -1603,10 +1609,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// Overrides any default or previously defined value for `name`.
|
||||
#[inline]
|
||||
pub fn field_with_id_from_iter<V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send>(
|
||||
pub fn field_with_id_from_iter<
|
||||
V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: impl AsRef<$crate::IdStr>,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.field_with_id(name, V::from_iter(iter))
|
||||
|
@ -1618,10 +1627,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// This has no effect if `iter` is empty, i.e. previous value for `name` is unchanged.
|
||||
#[inline]
|
||||
pub fn field_if_not_empty<V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send>(
|
||||
pub fn field_if_not_empty<
|
||||
V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: impl $crate::glib::IntoGStr,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -1638,10 +1650,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// This has no effect if `iter` is empty, i.e. previous value for `name` is unchanged.
|
||||
#[inline]
|
||||
pub fn field_with_static_if_not_empty<V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send>(
|
||||
pub fn field_with_static_if_not_empty<
|
||||
V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: impl AsRef<$crate::glib::GStr> + 'static,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -1658,10 +1673,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// This has no effect if `iter` is empty, i.e. previous value for `name` is unchanged.
|
||||
#[inline]
|
||||
pub fn field_with_id_if_not_empty<V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send>(
|
||||
pub fn field_with_id_if_not_empty
|
||||
<V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue> + Send,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: impl AsRef<IdStr>,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -1706,10 +1724,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// Overrides any default or previously defined value for `name`.
|
||||
#[inline]
|
||||
pub fn other_field_from_iter<V: $crate::glib::value::ValueType + $crate::glib::value::ToSendValue + FromIterator<$crate::glib::SendValue>>(
|
||||
pub fn other_field_from_iter<
|
||||
V: $crate::glib::value::ValueType + $crate::glib::value::ToSendValue + FromIterator<$crate::glib::SendValue>,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: &'a str,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.other_field(name, V::from_iter(iter))
|
||||
|
@ -1721,10 +1742,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// This has no effect if `iter` is empty, i.e. previous value for `name` is unchanged.
|
||||
#[inline]
|
||||
pub fn other_field_if_not_empty<V: $crate::glib::value::ValueType + $crate::glib::value::ToSendValue + FromIterator<$crate::glib::SendValue>>(
|
||||
pub fn other_field_if_not_empty<
|
||||
V: $crate::glib::value::ValueType + $crate::glib::value::ToSendValue + FromIterator<$crate::glib::SendValue>,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: &'a str,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
@ -1769,10 +1793,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// Overrides any default or previously defined value for `name`.
|
||||
#[inline]
|
||||
pub fn property_from_iter<V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue>>(
|
||||
pub fn property_from_iter<
|
||||
V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue>,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: &'a str,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let iter = iter.into_iter().map(|item| item.to_send_value());
|
||||
self.property(name, V::from_iter(iter))
|
||||
|
@ -1784,10 +1811,13 @@ macro_rules! impl_builder_gvalue_extra_setters (
|
|||
///
|
||||
/// This has no effect if `iter` is empty, i.e. previous value for `name` is unchanged.
|
||||
#[inline]
|
||||
pub fn property_if_not_empty<V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue>>(
|
||||
pub fn property_if_not_empty<
|
||||
V: $crate::glib::value::ValueType + Into<$crate::glib::Value> + FromIterator<$crate::glib::SendValue>,
|
||||
I: $crate::glib::value::ToSendValue,
|
||||
>(
|
||||
self,
|
||||
name: &'a str,
|
||||
iter: impl IntoIterator<Item = impl $crate::glib::value::ToSendValue>,
|
||||
iter: impl IntoIterator<Item = I>,
|
||||
) -> Self {
|
||||
let mut iter = iter.into_iter().peekable();
|
||||
if iter.peek().is_some() {
|
||||
|
|
Loading…
Reference in a new issue