object_rainbow/impls/
btree.rs

1use std::collections::{BTreeMap, BTreeSet};
2
3use crate::*;
4
5impl<T: ToOutput> ToOutput for BTreeSet<T> {
6    fn to_output(&self, output: &mut dyn Output) {
7        self.iter_to_output(output);
8    }
9}
10
11impl<T: Topological> Topological for BTreeSet<T> {
12    fn accept_points(&self, visitor: &mut impl PointVisitor) {
13        self.iter_accept_points(visitor);
14    }
15}
16
17impl<T: ParseInline<I> + Ord, I: ParseInput> Parse<I> for BTreeSet<T> {
18    fn parse(input: I) -> crate::Result<Self> {
19        input.parse_collect()
20    }
21}
22
23impl<T: Tagged> Tagged for BTreeSet<T> {
24    const TAGS: Tags = T::TAGS;
25}
26
27impl<T: Inline + Ord> Object for BTreeSet<T> {}
28
29impl<T: ReflessInline + Ord> ReflessObject for BTreeSet<T> {}
30
31impl<K: ToOutput, V: ToOutput> ToOutput for BTreeMap<K, V> {
32    fn to_output(&self, output: &mut dyn Output) {
33        self.iter_to_output(output);
34    }
35}
36
37impl<K: Topological, V: Topological> Topological for BTreeMap<K, V> {
38    fn accept_points(&self, visitor: &mut impl PointVisitor) {
39        self.iter_accept_points(visitor);
40    }
41}
42
43impl<K: ParseInline<I> + Ord, V: ParseInline<I>, I: ParseInput> Parse<I> for BTreeMap<K, V> {
44    fn parse(input: I) -> crate::Result<Self> {
45        input.parse_collect()
46    }
47}
48
49impl<K: Tagged, V: Tagged> Tagged for BTreeMap<K, V> {
50    const TAGS: Tags = Tags(&[], &[&K::TAGS, &V::TAGS]);
51}
52
53impl<K: Inline + Ord, V: Inline> Object for BTreeMap<K, V> {}
54
55impl<K: ReflessInline + Ord, V: ReflessInline> ReflessObject for BTreeMap<K, V> {}
56
57impl<K: Ord> Equivalent<BTreeMap<K, ()>> for BTreeSet<K> {
58    fn into_equivalent(self) -> BTreeMap<K, ()> {
59        self.into_iter().map(|k| (k, ())).collect()
60    }
61
62    fn from_equivalent(object: BTreeMap<K, ()>) -> Self {
63        object.into_iter().map(|(k, ())| k).collect()
64    }
65}