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