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 dyn 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<K: InlineOutput, V: InlineOutput> ToOutput for BTreeMap<K, V> {
34 fn to_output(&self, output: &mut dyn Output) {
35 self.iter_to_output(output);
36 }
37}
38
39impl<K: ListHashes, V: ListHashes> ListHashes for BTreeMap<K, V> {
40 fn list_hashes(&self, f: &mut impl FnMut(Hash)) {
41 self.iter_list_hashes(f);
42 }
43}
44
45impl<K: Topological, V: Topological> Topological for BTreeMap<K, V> {
46 fn traverse(&self, visitor: &mut impl PointVisitor) {
47 self.iter_traverse(visitor);
48 }
49}
50
51impl<K: ParseInline<I> + Ord, V: ParseInline<I>, I: ParseInput> Parse<I> for BTreeMap<K, V> {
52 fn parse(input: I) -> crate::Result<Self> {
53 input.parse_collect()
54 }
55}
56
57impl<K: Tagged, V: Tagged> Tagged for BTreeMap<K, V> {
58 const TAGS: Tags = Tags(&[], &[&K::TAGS, &V::TAGS]);
59}
60
61impl<K: Ord> Equivalent<BTreeMap<K, ()>> for BTreeSet<K> {
62 fn into_equivalent(self) -> BTreeMap<K, ()> {
63 self.into_iter().map(|k| (k, ())).collect()
64 }
65
66 fn from_equivalent(object: BTreeMap<K, ()>) -> Self {
67 object.into_iter().map(|(k, ())| k).collect()
68 }
69}