algebraeon_sets/structure/
empty_set.rs

1use super::{EqSignature, OrdSignature, SetSignature, Signature};
2use std::fmt::Debug;
3use std::marker::PhantomData;
4
5pub struct EmptySetStructure<Set> {
6    _set: PhantomData<Set>,
7}
8
9impl<Set> Clone for EmptySetStructure<Set> {
10    fn clone(&self) -> Self {
11        Self { _set: PhantomData }
12    }
13}
14
15impl<Set> Debug for EmptySetStructure<Set> {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        f.debug_struct("EmptySetStructure").finish()
18    }
19}
20
21impl<Set> PartialEq for EmptySetStructure<Set> {
22    fn eq(&self, _: &Self) -> bool {
23        true
24    }
25}
26
27impl<Set> Eq for EmptySetStructure<Set> {}
28
29impl<Set> Default for EmptySetStructure<Set> {
30    fn default() -> Self {
31        Self { _set: PhantomData }
32    }
33}
34
35impl<Set> Signature for EmptySetStructure<Set> {}
36
37impl<Set: Debug + Clone> SetSignature for EmptySetStructure<Set> {
38    type Set = Set;
39
40    fn is_element(&self, _: &Self::Set) -> Result<(), String> {
41        Err("Empty set has no elements".to_string())
42    }
43}
44
45impl<Set: Debug + Clone> EqSignature for EmptySetStructure<Set> {
46    fn equal(&self, _: &Self::Set, _: &Self::Set) -> bool {
47        panic!("Empty set had no elements to compare for equality")
48    }
49}
50
51impl<Set: Debug + Clone> OrdSignature for EmptySetStructure<Set> {
52    fn cmp(&self, _: &Self::Set, _: &Self::Set) -> std::cmp::Ordering {
53        panic!("Empty set had no elements to compare for ordering")
54    }
55}