Skip to main content

ferroui_xaml_interactivity/core/
condition_collection.rs

1//! Port of `Core/ConditionCollection.cs`.
2
3use crate::Condition;
4use ferroui_base::collections::FerroList;
5use ferroui_base::Ref;
6use std::ops::Deref;
7
8/// Represents a collection of [`Condition`] objects.
9///
10/// It is a reference object: clones refer to the same collection and compare by identity.
11#[derive(Clone, PartialEq)]
12pub struct ConditionCollection(FerroList<Ref<Condition>>);
13
14impl ConditionCollection {
15    /// Creates an empty collection.
16    pub fn new() -> Self {
17        Self(FerroList::new())
18    }
19
20    /// The list of the collection.
21    pub fn list(&self) -> &FerroList<Ref<Condition>> {
22        &self.0
23    }
24}
25
26impl Default for ConditionCollection {
27    fn default() -> Self {
28        Self::new()
29    }
30}
31
32impl Deref for ConditionCollection {
33    type Target = FerroList<Ref<Condition>>;
34
35    fn deref(&self) -> &FerroList<Ref<Condition>> {
36        &self.0
37    }
38}
39
40impl std::fmt::Debug for ConditionCollection {
41    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42        write!(f, "ConditionCollection({})", self.0.count())
43    }
44}