1use crate :: *;
9#[ allow( unused ) ]
10use collection_tools ::BTreeSet;
11
12impl< E > Collection for BTreeSet< E >
13{
14 type Entry = E;
15 type Val = E;
16
17 #[ inline( always ) ]
18 fn entry_to_val(e: Self ::Entry) -> Self ::Val
19 {
20 e
21 }
22}
23
24impl< E > CollectionAdd for BTreeSet< E >
25where
26 E: Ord,
27{
28 #[ inline( always ) ]
29 fn add(&mut self, e: Self ::Entry) -> bool
30 {
31 self.insert(e);
32 true
33 }
34}
35
36impl< E > CollectionAssign for BTreeSet< E >
37where
38 E: Ord,
39{
40 #[ inline( always ) ]
41 fn assign< Elements >(&mut self, elements: Elements) -> usize
42 where
43 Elements: IntoIterator< Item = Self ::Entry >,
44 {
45 let initial_len = self.len();
46 self.extend(elements);
47 self.len() - initial_len
48 }
49}
50
51impl< E > CollectionValToEntry< E > for BTreeSet< E >
52{
53 type Entry = E;
54 #[ inline( always ) ]
55 fn val_to_entry(val: E) -> Self ::Entry
56 {
57 val
58 }
59}
60
61impl< E > Storage for BTreeSet< E >
64{
65 type Preformed = BTreeSet< E >;
66}
67
68impl< E > StoragePreform for BTreeSet< E >
69{
70 fn preform(self) -> Self ::Preformed
71 {
72 self
73 }
74}
75
76#[ derive( Debug, Default ) ]
90pub struct BTreeSetDefinition< E, Context, Formed, End >
91where
92 End: FormingEnd< BTreeSetDefinitionTypes<E, Context, Formed >>,
93{
94 _phantom: core ::marker ::PhantomData< (E, Context, Formed, End) >,
95}
96
97impl< E, Context, Formed, End > FormerDefinition for BTreeSetDefinition< E, Context, Formed, End >
98where
99 End: FormingEnd< BTreeSetDefinitionTypes<E, Context, Formed >>,
100{
101 type Storage = BTreeSet< E >;
102 type Context = Context;
103 type Formed = Formed;
104
105 type Types = BTreeSetDefinitionTypes< E, Context, Formed >;
106 type End = End;
107}
108
109#[ derive( Debug, Default ) ]
123pub struct BTreeSetDefinitionTypes< E, Context = (), Formed = BTreeSet<E >>
124{
125 _phantom: core ::marker ::PhantomData< (E, Context, Formed) >,
126}
127
128impl< E, Context, Formed > FormerDefinitionTypes for BTreeSetDefinitionTypes< E, Context, Formed >
129{
130 type Storage = BTreeSet< E >;
131 type Context = Context;
132 type Formed = Formed;
133}
134
135impl< E, Context, Formed > FormerMutator for BTreeSetDefinitionTypes< E, Context, Formed > {}
138
139impl< E, Definition > EntityToFormer< Definition > for BTreeSet< E >
142where
143 E: Ord,
144 Definition: FormerDefinition<
145 Storage = BTreeSet< E >,
146 Types = BTreeSetDefinitionTypes<
147 E,
148 < Definition as definition ::FormerDefinition > ::Context,
149 < Definition as definition ::FormerDefinition > ::Formed,
150 >,
151 >,
152 Definition ::End: forming ::FormingEnd< Definition ::Types >,
153{
154 type Former = BTreeSetFormer< E, Definition ::Context, Definition ::Formed, Definition ::End >;
155}
156
157impl< E > crate ::EntityToStorage for BTreeSet< E >
158{
159 type Storage = BTreeSet< E >;
160}
161
162impl< E, Context, Formed, End > crate ::EntityToDefinition< Context, Formed, End > for BTreeSet< E >
163where
164 End: crate ::FormingEnd< BTreeSetDefinitionTypes<E, Context, Formed >>,
165{
166 type Definition = BTreeSetDefinition< E, Context, Formed, End >;
167 type Types = BTreeSetDefinitionTypes< E, Context, Formed >;
168}
169
170impl< E, Context, Formed > crate ::EntityToDefinitionTypes< Context, Formed > for BTreeSet< E >
171{
172 type Types = BTreeSetDefinitionTypes< E, Context, Formed >;
173}
174
175pub type BTreeSetFormer< E, Context, Formed, End > = CollectionFormer< E, BTreeSetDefinition<E, Context, Formed, End >>;
189
190pub trait BTreeSetExt< E > : sealed ::Sealed
200where
201 E: Ord,
202{
203 fn former() -> BTreeSetFormer< E, (), BTreeSet<E >, ReturnStorage>;
205}
206
207impl< E > BTreeSetExt< E > for BTreeSet< E >
208where
209 E: Ord,
210{
211 #[ allow( clippy ::default_constructed_unit_structs ) ]
212 fn former() -> BTreeSetFormer< E, (), BTreeSet<E >, ReturnStorage>
213 {
214 BTreeSetFormer :: < E, (), BTreeSet<E >, ReturnStorage> ::new(ReturnStorage ::default())
215 }
216}
217
218mod sealed
219{
220 pub trait Sealed {}
221 impl< E > Sealed for super ::BTreeSet< E > {}
222}