ferroui_dynamic_data/cache/
immutable_group_change_set.rs1use super::{Change, ChangeSet, IChangeSet, ImmutableGroup};
5use std::fmt;
6use std::ops::Deref;
7
8pub struct ImmutableGroupChangeSet<T, K, G> {
15 changes: ChangeSet<ImmutableGroup<T, K, G>, G>,
16}
17
18impl<T, K, G> Clone for ImmutableGroupChangeSet<T, K, G> {
19 fn clone(&self) -> Self {
20 Self { changes: self.changes.clone() }
21 }
22}
23
24impl<T, K, G> Default for ImmutableGroupChangeSet<T, K, G> {
25 fn default() -> Self {
26 Self::empty()
27 }
28}
29
30impl<T, K, G> ImmutableGroupChangeSet<T, K, G> {
31 pub fn empty() -> Self {
33 Self { changes: ChangeSet::empty() }
34 }
35
36 pub fn change_set(&self) -> &ChangeSet<ImmutableGroup<T, K, G>, G> {
38 &self.changes
39 }
40}
41
42impl<T, K, G> From<ChangeSet<ImmutableGroup<T, K, G>, G>> for ImmutableGroupChangeSet<T, K, G> {
43 fn from(changes: ChangeSet<ImmutableGroup<T, K, G>, G>) -> Self {
44 Self { changes }
45 }
46}
47
48impl<T, K, G> From<Vec<Change<ImmutableGroup<T, K, G>, G>>> for ImmutableGroupChangeSet<T, K, G> {
49 fn from(changes: Vec<Change<ImmutableGroup<T, K, G>, G>>) -> Self {
51 Self { changes: ChangeSet::from(changes) }
52 }
53}
54
55impl<T, K, G> Deref for ImmutableGroupChangeSet<T, K, G> {
56 type Target = ChangeSet<ImmutableGroup<T, K, G>, G>;
57
58 fn deref(&self) -> &Self::Target {
59 &self.changes
60 }
61}
62
63impl<'a, T, K, G> IntoIterator for &'a ImmutableGroupChangeSet<T, K, G> {
64 type Item = &'a Change<ImmutableGroup<T, K, G>, G>;
65 type IntoIter = std::slice::Iter<'a, Change<ImmutableGroup<T, K, G>, G>>;
66
67 fn into_iter(self) -> Self::IntoIter {
68 self.changes.changes().iter()
69 }
70}
71
72impl<T: 'static, K: 'static, G: 'static> IChangeSet<ImmutableGroup<T, K, G>, G> for ImmutableGroupChangeSet<T, K, G> {
73 fn change_set(&self) -> &ChangeSet<ImmutableGroup<T, K, G>, G> {
74 &self.changes
75 }
76}
77
78impl<T, K, G: PartialEq> PartialEq for ImmutableGroupChangeSet<T, K, G> {
79 fn eq(&self, other: &Self) -> bool {
80 self.changes == other.changes
81 }
82}
83
84impl<T: Clone, K: Eq + std::hash::Hash + Clone, G: fmt::Debug> fmt::Debug for ImmutableGroupChangeSet<T, K, G> {
85 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
86 fmt::Debug::fmt(&self.changes, f)
87 }
88}