1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::prelude::*;
use crate::ListModel;
pub trait ListModelExtManual: Sized {
fn snapshot(&self) -> Vec<glib::Object>;
}
impl<T: IsA<ListModel>> ListModelExtManual for T {
fn snapshot(&self) -> Vec<glib::Object> {
let mut res = Vec::with_capacity(self.n_items() as usize);
for i in 0..self.n_items() {
res.push(self.item(i).unwrap())
}
res
}
}
impl std::iter::IntoIterator for ListModel {
type Item = glib::Object;
type IntoIter = std::vec::IntoIter<glib::Object>;
fn into_iter(self) -> Self::IntoIter {
self.snapshot().into_iter()
}
}