object_rainbow/impls/
btree.rs1use std::collections::{BTreeMap, BTreeSet};
2
3use crate::*;
4
5impl<T: InlineOutput> ToOutput for BTreeSet<T> {
6 fn to_output(&self, output: &mut impl Output) {
7 self.iter_to_output(output);
8 }
9}
10
11impl<T: ListHashes> ListHashes for BTreeSet<T> {
12 fn list_hashes(&self, f: &mut impl FnMut(Hash)) {
13 self.iter_list_hashes(f);
14 }
15}
16
17impl<T: Topological> Topological for BTreeSet<T> {
18 fn traverse(&self, visitor: &mut impl PointVisitor) {
19 self.iter_traverse(visitor);
20 }
21}
22
23impl<T: ParseInline<I> + Ord, I: ParseInput> Parse<I> for BTreeSet<T> {
24 fn parse(input: I) -> crate::Result<Self> {
25 input.parse_collect()
26 }
27}
28
29impl<T: Tagged> Tagged for BTreeSet<T> {
30 const TAGS: Tags = T::TAGS;
31}
32
33impl<T: ByteOrd + InlineOutput> ByteOrd for BTreeSet<T> {
34 fn bytes_cmp(&self, other: &Self) -> Ordering {
35 self.iter_bytes_cmp(other)
36 }
37}
38
39impl<K: InlineOutput, V: InlineOutput> ToOutput for BTreeMap<K, V> {
40 fn to_output(&self, output: &mut impl Output) {
41 self.iter_to_output(output);
42 }
43}
44
45impl<K: ListHashes, V: ListHashes> ListHashes for BTreeMap<K, V> {
46 fn list_hashes(&self, f: &mut impl FnMut(Hash)) {
47 self.iter_list_hashes(f);
48 }
49}
50
51impl<K: Topological, V: Topological> Topological for BTreeMap<K, V> {
52 fn traverse(&self, visitor: &mut impl PointVisitor) {
53 self.iter_traverse(visitor);
54 }
55}
56
57impl<K: ParseInline<I> + Ord, V: ParseInline<I>, I: ParseInput> Parse<I> for BTreeMap<K, V> {
58 fn parse(input: I) -> crate::Result<Self> {
59 input.parse_collect()
60 }
61}
62
63impl<K: Tagged, V: Tagged> Tagged for BTreeMap<K, V> {
64 const TAGS: Tags = Tags(&[], &[&K::TAGS, &V::TAGS]);
65}
66
67impl<K: ByteOrd + InlineOutput, V: ByteOrd + InlineOutput> ByteOrd for BTreeMap<K, V> {
68 fn bytes_cmp(&self, other: &Self) -> Ordering {
69 self.iter_bytes_cmp(other)
70 }
71}
72
73impl<K: Ord> Equivalent<BTreeMap<K, ()>> for BTreeSet<K> {
74 fn into_equivalent(self) -> BTreeMap<K, ()> {
75 self.into_iter().map(|k| (k, ())).collect()
76 }
77
78 fn from_equivalent(object: BTreeMap<K, ()>) -> Self {
79 object.into_iter().map(|(k, ())| k).collect()
80 }
81}