mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
gstreamer: Remove FromIterator impls on references
Creating copies silently while calling collect() is unexpected and can explicitly added to the iterator via map() if needed.
This commit is contained in:
parent
3670076f07
commit
e989899467
2 changed files with 2 additions and 46 deletions
|
@ -281,22 +281,6 @@ impl<'a> IntoIterator for &'a BufferListRef {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> std::iter::FromIterator<&'a BufferRef> for BufferList {
|
||||
fn from_iter<T: IntoIterator<Item = &'a BufferRef>>(iter: T) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
let iter = iter.into_iter();
|
||||
|
||||
let mut list = BufferList::new_sized(iter.size_hint().0);
|
||||
|
||||
{
|
||||
let list = list.get_mut().unwrap();
|
||||
iter.for_each(|b| list.add(b.to_owned()));
|
||||
}
|
||||
|
||||
list
|
||||
}
|
||||
}
|
||||
|
||||
impl std::iter::FromIterator<Buffer> for BufferList {
|
||||
fn from_iter<T: IntoIterator<Item = Buffer>>(iter: T) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
|
|
@ -144,21 +144,6 @@ impl str::FromStr for Caps {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> std::iter::FromIterator<&'a StructureRef> for Caps {
|
||||
fn from_iter<T: IntoIterator<Item = &'a StructureRef>>(iter: T) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
let mut caps = Caps::new_empty();
|
||||
|
||||
{
|
||||
let caps = caps.get_mut().unwrap();
|
||||
iter.into_iter()
|
||||
.for_each(|s| caps.append_structure(s.to_owned()));
|
||||
}
|
||||
|
||||
caps
|
||||
}
|
||||
}
|
||||
|
||||
impl std::iter::FromIterator<Structure> for Caps {
|
||||
fn from_iter<T: IntoIterator<Item = Structure>>(iter: T) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
@ -173,21 +158,6 @@ impl std::iter::FromIterator<Structure> for Caps {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> std::iter::FromIterator<(&'a StructureRef, &'b CapsFeaturesRef)> for Caps {
|
||||
fn from_iter<T: IntoIterator<Item = (&'a StructureRef, &'b CapsFeaturesRef)>>(iter: T) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
let mut caps = Caps::new_empty();
|
||||
|
||||
{
|
||||
let caps = caps.get_mut().unwrap();
|
||||
iter.into_iter()
|
||||
.for_each(|(s, f)| caps.append_structure_full(s.to_owned(), Some(f.to_owned())));
|
||||
}
|
||||
|
||||
caps
|
||||
}
|
||||
}
|
||||
|
||||
impl std::iter::FromIterator<(Structure, CapsFeatures)> for Caps {
|
||||
fn from_iter<T: IntoIterator<Item = (Structure, CapsFeatures)>>(iter: T) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
@ -981,12 +951,14 @@ mod tests {
|
|||
let audio = caps
|
||||
.iter()
|
||||
.filter(|s| s.name() == "audio/x-raw")
|
||||
.map(|s| s.to_owned())
|
||||
.collect::<Caps>();
|
||||
assert_eq!(audio.to_string(), "audio/x-raw");
|
||||
|
||||
let audio = caps
|
||||
.iter_with_features()
|
||||
.filter(|(s, _)| s.name() == "audio/x-raw")
|
||||
.map(|(s, c)| (s.to_owned(), c.to_owned()))
|
||||
.collect::<Caps>();
|
||||
assert_eq!(audio.to_string(), "audio/x-raw(ANY)");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue