diagweave 0.1.1

Core runtime and macros re-export for diagweave error algebra and report diagweaveing.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
#[cfg(not(feature = "std"))]
use alloc::collections::{BTreeMap, BTreeSet};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::borrow::Borrow;
use core::convert::TryFrom;
use core::fmt::{self, Display, Formatter};
#[cfg(feature = "std")]
use core::hash::Hash;
use ref_str::StaticRefStr;
#[cfg(feature = "std")]
use std::collections::{HashMap, HashSet};

#[derive(Clone, Copy, PartialEq, Eq)]
/// Fixed-length non-zero hexadecimal identifier.
pub struct HexId<const N: usize>([u8; N]);

impl<const N: usize> fmt::Debug for HexId<N> {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        write!(f, "HexId({})", self.as_str())
    }
}

impl<const N: usize> HexId<N> {
    /// Creates a validated hexadecimal identifier.
    pub const fn new(value: [u8; N]) -> Result<Self, &'static str> {
        let mut i = 0;
        let mut all_zeros = true;

        while i < N {
            let b = value[i];
            if !b.is_ascii_hexdigit() {
                return Err("invalid hex id: contains non-hex characters");
            }
            if b != b'0' {
                all_zeros = false;
            }
            i += 1;
        }

        if all_zeros {
            return Err("invalid hex id: cannot be all zeros");
        }

        Ok(Self(value))
    }

    /// Creates an unchecked identifier.
    ///
    /// # Safety
    ///
    /// The caller must ensure that `value` is a valid hexadecimal identifier.
    pub const unsafe fn new_unchecked(value: [u8; N]) -> Self {
        Self(value)
    }

    /// Creates a validated hexadecimal identifier from a byte slice.
    ///
    /// If the slice length is less than N, the identifier is padded with '0' bytes at the beginning.
    /// For example, if N=4 and the input is "ab", the result will be "00ab".
    pub const fn from_bytes(value: &[u8]) -> Result<Self, &'static str> {
        let len = value.len();
        if len > N {
            return Err("invalid hex id: input too long");
        }
        if len == 0 {
            return Err("invalid hex id: input is empty");
        }

        let mut bytes = [b'0'; N];
        let mut i = 0;
        let offset = N - len;
        let mut all_zeros = true;

        while i < len {
            let b = value[i];
            if !b.is_ascii_hexdigit() {
                return Err("invalid hex id: contains non-hex characters");
            }
            if b != b'0' {
                all_zeros = false;
            }
            bytes[offset + i] = b;
            i += 1;
        }

        if all_zeros {
            return Err("invalid hex id: cannot be all zeros");
        }

        Ok(Self(bytes))
    }

    /// Creates a validated hexadecimal identifier from a str.
    pub const fn from_str(value: &str) -> Result<Self, &'static str> {
        let slice = value.as_bytes();
        if slice.len() != N {
            return Err("invalid hex id: length mismatch");
        }

        let mut bytes = [0u8; N];
        let mut i = 0;
        let mut all_zeros = true;

        while i < N {
            let b = slice[i];
            if !b.is_ascii_hexdigit() {
                return Err("invalid hex id: contains non-hex characters");
            }
            if b != b'0' {
                all_zeros = false;
            }
            bytes[i] = b;
            i += 1;
        }

        if all_zeros {
            return Err("invalid hex id: cannot be all zeros");
        }

        Ok(Self(bytes))
    }

    /// Creates an unchecked identifier from a str.
    ///
    /// # Safety
    ///
    /// The caller must ensure that `value` is a valid hexadecimal identifier.
    pub const unsafe fn from_str_unchecked(value: &str) -> Self {
        let slice = value.as_bytes();
        let mut bytes = [0u8; N];
        let mut i = 0;
        while i < N {
            bytes[i] = slice[i];
            i += 1;
        }
        Self(bytes)
    }

    /// Returns the owned inner bytes.
    pub const fn into_inner(self) -> [u8; N] {
        self.0
    }

    /// Returns the identifier as a string slice.
    pub const fn as_str(&self) -> &str {
        // SAFETY: HexId is always validated to be ASCII hex digits during construction.
        unsafe { core::str::from_utf8_unchecked(&self.0) }
    }
}

impl<const N: usize> TryFrom<[u8; N]> for HexId<N> {
    type Error = &'static str;
    fn try_from(value: [u8; N]) -> Result<Self, Self::Error> {
        Self::new(value)
    }
}

impl<'a, const N: usize> TryFrom<&'a str> for HexId<N> {
    type Error = &'static str;
    fn try_from(value: &'a str) -> Result<Self, Self::Error> {
        Self::from_str(value)
    }
}

#[cfg(feature = "json")]
impl<const N: usize> serde::Serialize for HexId<N> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

#[cfg(feature = "json")]
impl<'de, const N: usize> serde::Deserialize<'de> for HexId<N> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        struct HexIdVisitor<const N: usize>;

        impl<'de, const N: usize> serde::de::Visitor<'de> for HexIdVisitor<N> {
            type Value = HexId<N>;

            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                write!(formatter, "a hex string of length {}", N)
            }

            fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
            where
                E: serde::de::Error,
            {
                HexId::from_str(v).map_err(E::custom)
            }
        }

        deserializer.deserialize_str(HexIdVisitor::<N>)
    }
}

impl<const N: usize> AsRef<str> for HexId<N> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<const N: usize> core::ops::Deref for HexId<N> {
    type Target = str;

    fn deref(&self) -> &Self::Target {
        self.as_str()
    }
}

impl<const N: usize> Display for HexId<N> {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        f.write_str(self.as_str())
    }
}

/// 16-byte trace id encoded as 32 lowercase hex chars.
pub type TraceId = HexId<32>;

#[cfg(feature = "opentelemetry")]
impl TryFrom<opentelemetry::TraceId> for TraceId {
    type Error = &'static str;
    fn try_from(value: opentelemetry::TraceId) -> Result<Self, Self::Error> {
        Self::from_bytes(value.to_bytes().as_ref())
    }
}

/// 8-byte span id encoded as 16 lowercase hex chars.
pub type SpanId = HexId<16>;

#[cfg(feature = "opentelemetry")]
impl TryFrom<opentelemetry::SpanId> for SpanId {
    type Error = &'static str;
    fn try_from(value: opentelemetry::SpanId) -> Result<Self, Self::Error> {
        Self::from_bytes(value.to_bytes().as_ref())
    }
}
/// Parent span id encoded as 16 lowercase hex chars.
pub type ParentSpanId = HexId<16>;

#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "json", derive(serde::Serialize, serde::Deserialize))]
pub struct TraceState(StaticRefStr);

impl TraceState {
    pub fn new(value: impl Into<StaticRefStr>) -> Self {
        Self(value.into())
    }

    pub fn as_str(&self) -> &str {
        self.0.as_ref()
    }

    pub fn as_static_ref(&self) -> &StaticRefStr {
        &self.0
    }

    pub fn into_inner(self) -> StaticRefStr {
        self.0
    }
}

impl From<StaticRefStr> for TraceState {
    fn from(value: StaticRefStr) -> Self {
        Self(value)
    }
}

impl AsRef<str> for TraceState {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl core::ops::Deref for TraceState {
    type Target = str;

    fn deref(&self) -> &Self::Target {
        self.as_ref()
    }
}

impl Display for TraceState {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(feature = "std")]
type FastMapImpl<K, V> = HashMap<K, V>;
#[cfg(not(feature = "std"))]
type FastMapImpl<K, V> = BTreeMap<K, V>;

#[cfg(feature = "std")]
type FastSetImpl<T> = HashSet<T>;
#[cfg(not(feature = "std"))]
type FastSetImpl<T> = BTreeSet<T>;

/// Fast map wrapper optimized for the current target environment.
#[derive(Debug, Clone)]
pub struct FastMap<K, V>(FastMapImpl<K, V>);

impl<K, V> Default for FastMap<K, V>
where
    FastMapImpl<K, V>: Default,
{
    fn default() -> Self {
        Self::new()
    }
}

impl<K, V> PartialEq for FastMap<K, V>
where
    FastMapImpl<K, V>: PartialEq,
{
    fn eq(&self, other: &Self) -> bool {
        self.0 == other.0
    }
}

impl<K, V> Eq for FastMap<K, V> where FastMapImpl<K, V>: Eq {}

#[cfg(feature = "json")]
impl<K, V> serde::Serialize for FastMap<K, V>
where
    FastMapImpl<K, V>: serde::Serialize,
{
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        self.0.serialize(serializer)
    }
}

#[cfg(feature = "json")]
impl<'de, K, V> serde::Deserialize<'de> for FastMap<K, V>
where
    FastMapImpl<K, V>: serde::Deserialize<'de>,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        FastMapImpl::<K, V>::deserialize(deserializer).map(Self)
    }
}

impl<K, V> FastMap<K, V> {
    /// Creates an empty fast map.
    pub fn new() -> Self {
        Self(FastMapImpl::default())
    }

    /// Returns true if the map contains no elements.
    pub fn is_empty(&self) -> bool {
        self.0.is_empty()
    }

    /// Returns the number of elements in the map.
    pub fn len(&self) -> usize {
        self.0.len()
    }

    /// Removes all key-value pairs from the map.
    pub fn clear(&mut self) {
        self.0.clear();
    }

    /// Returns an iterator over key-value pairs.
    pub fn iter(&self) -> impl Iterator<Item = (&K, &V)> {
        self.0.iter()
    }

    /// Returns a mutable iterator over key-value pairs.
    pub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut V)> {
        self.0.iter_mut()
    }
}

#[cfg(feature = "std")]
impl<K, V> FastMap<K, V>
where
    K: Eq + Hash + Ord,
{
    /// Returns all entries sorted by key.
    pub fn sorted_entries(&self) -> Vec<(&K, &V)> {
        let mut entries: Vec<_> = self.0.iter().collect();
        entries.sort_by_key(|(left, _)| *left);
        entries
    }

    /// Consumes the map and returns all entries sorted by key.
    pub fn into_sorted_entries(self) -> Vec<(K, V)> {
        let mut entries: Vec<_> = self.0.into_iter().collect();
        entries.sort_by(|(left, _), (right, _)| left.cmp(right));
        entries
    }
}

#[cfg(not(feature = "std"))]
impl<K, V> FastMap<K, V>
where
    K: Ord,
{
    /// Returns all entries sorted by key.
    pub fn sorted_entries(&self) -> Vec<(&K, &V)> {
        self.0.iter().collect()
    }

    /// Consumes the map and returns all entries sorted by key.
    pub fn into_sorted_entries(self) -> Vec<(K, V)> {
        self.0.into_iter().collect()
    }
}

#[cfg(feature = "std")]
impl<K, V> FastMap<K, V> {
    /// Creates a fast map with the requested capacity.
    pub fn with_capacity(capacity: usize) -> Self {
        Self(HashMap::with_capacity(capacity))
    }
}

#[cfg(not(feature = "std"))]
impl<K, V> FastMap<K, V> {
    /// Creates a fast map with the requested capacity hint.
    pub fn with_capacity(_: usize) -> Self {
        Self(BTreeMap::new())
    }
}

#[cfg(feature = "std")]
impl<K, V> FastMap<K, V>
where
    K: Eq + Hash,
{
    /// Inserts a key-value pair into the map.
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
        self.0.insert(key, value)
    }

    /// Returns a shared reference to the value corresponding to the key.
    pub fn get<Q>(&self, key: &Q) -> Option<&V>
    where
        K: Borrow<Q>,
        Q: ?Sized + Eq + Hash,
    {
        self.0.get(key)
    }

    /// Returns a mutable reference to the value corresponding to the key.
    pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
    where
        K: Borrow<Q>,
        Q: ?Sized + Eq + Hash,
    {
        self.0.get_mut(key)
    }

    /// Returns true if the map contains a value for the specified key.
    pub fn contains_key<Q>(&self, key: &Q) -> bool
    where
        K: Borrow<Q>,
        Q: ?Sized + Eq + Hash,
    {
        self.0.contains_key(key)
    }

    /// Removes a key from the map, returning the value if the key was in the map.
    pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
    where
        K: Borrow<Q>,
        Q: ?Sized + Eq + Hash,
    {
        self.0.remove(key)
    }
}

#[cfg(not(feature = "std"))]
impl<K, V> FastMap<K, V>
where
    K: Ord,
{
    /// Inserts a key-value pair into the map.
    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
        self.0.insert(key, value)
    }

    /// Returns a shared reference to the value corresponding to the key.
    pub fn get<Q>(&self, key: &Q) -> Option<&V>
    where
        K: Borrow<Q>,
        Q: ?Sized + Ord,
    {
        self.0.get(key)
    }

    /// Returns a mutable reference to the value corresponding to the key.
    pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
    where
        K: Borrow<Q>,
        Q: ?Sized + Ord,
    {
        self.0.get_mut(key)
    }

    /// Returns true if the map contains a value for the specified key.
    pub fn contains_key<Q>(&self, key: &Q) -> bool
    where
        K: Borrow<Q>,
        Q: ?Sized + Ord,
    {
        self.0.contains_key(key)
    }

    /// Removes a key from the map, returning the value if the key was in the map.
    pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
    where
        K: Borrow<Q>,
        Q: ?Sized + Ord,
    {
        self.0.remove(key)
    }
}

impl<K, V> Extend<(K, V)> for FastMap<K, V>
where
    FastMapImpl<K, V>: Extend<(K, V)>,
{
    fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T) {
        self.0.extend(iter);
    }
}

impl<K, V> FromIterator<(K, V)> for FastMap<K, V>
where
    FastMapImpl<K, V>: FromIterator<(K, V)>,
{
    fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
        Self(iter.into_iter().collect())
    }
}

impl<K, V> IntoIterator for FastMap<K, V> {
    type Item = (K, V);
    type IntoIter = <FastMapImpl<K, V> as IntoIterator>::IntoIter;

    fn into_iter(self) -> Self::IntoIter {
        self.0.into_iter()
    }
}

impl<'a, K, V> IntoIterator for &'a FastMap<K, V> {
    type Item = (&'a K, &'a V);
    type IntoIter = <&'a FastMapImpl<K, V> as IntoIterator>::IntoIter;

    fn into_iter(self) -> Self::IntoIter {
        self.0.iter()
    }
}

impl<'a, K, V> IntoIterator for &'a mut FastMap<K, V> {
    type Item = (&'a K, &'a mut V);
    type IntoIter = <&'a mut FastMapImpl<K, V> as IntoIterator>::IntoIter;

    fn into_iter(self) -> Self::IntoIter {
        self.0.iter_mut()
    }
}

/// Fast set wrapper optimized for the current target environment.
#[derive(Debug, Clone)]
pub struct FastSet<T>(FastSetImpl<T>);

impl<T> Default for FastSet<T>
where
    FastSetImpl<T>: Default,
{
    fn default() -> Self {
        Self::new()
    }
}

impl<T> PartialEq for FastSet<T>
where
    FastSetImpl<T>: PartialEq,
{
    fn eq(&self, other: &Self) -> bool {
        self.0 == other.0
    }
}

impl<T> Eq for FastSet<T> where FastSetImpl<T>: Eq {}

#[cfg(feature = "json")]
impl<T> serde::Serialize for FastSet<T>
where
    FastSetImpl<T>: serde::Serialize,
{
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        self.0.serialize(serializer)
    }
}

#[cfg(feature = "json")]
impl<'de, T> serde::Deserialize<'de> for FastSet<T>
where
    FastSetImpl<T>: serde::Deserialize<'de>,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        FastSetImpl::<T>::deserialize(deserializer).map(Self)
    }
}

impl<T> FastSet<T> {
    /// Creates an empty fast set.
    pub fn new() -> Self {
        Self(FastSetImpl::default())
    }

    /// Returns true if the set contains no elements.
    pub fn is_empty(&self) -> bool {
        self.0.is_empty()
    }

    /// Returns the number of elements in the set.
    pub fn len(&self) -> usize {
        self.0.len()
    }

    /// Removes all elements from the set.
    pub fn clear(&mut self) {
        self.0.clear();
    }

    /// Returns an iterator over all values in the set.
    pub fn iter(&self) -> impl Iterator<Item = &T> {
        self.0.iter()
    }
}

#[cfg(feature = "std")]
impl<T> FastSet<T> {
    /// Creates a fast set with the requested capacity.
    pub fn with_capacity(capacity: usize) -> Self {
        Self(HashSet::with_capacity(capacity))
    }
}

#[cfg(not(feature = "std"))]
impl<T> FastSet<T> {
    /// Creates a fast set with the requested capacity hint.
    pub fn with_capacity(_: usize) -> Self {
        Self(BTreeSet::new())
    }
}

#[cfg(feature = "std")]
impl<T> FastSet<T>
where
    T: Eq + Hash,
{
    /// Adds a value to the set. Returns true if the value was not present.
    pub fn insert(&mut self, value: T) -> bool {
        self.0.insert(value)
    }

    /// Returns true if the set contains the value.
    pub fn contains<Q>(&self, value: &Q) -> bool
    where
        T: Borrow<Q>,
        Q: ?Sized + Eq + Hash,
    {
        self.0.contains(value)
    }

    /// Removes a value from the set. Returns true if the value existed.
    pub fn remove<Q>(&mut self, value: &Q) -> bool
    where
        T: Borrow<Q>,
        Q: ?Sized + Eq + Hash,
    {
        self.0.remove(value)
    }
}

#[cfg(not(feature = "std"))]
impl<T> FastSet<T>
where
    T: Ord,
{
    /// Adds a value to the set. Returns true if the value was not present.
    pub fn insert(&mut self, value: T) -> bool {
        self.0.insert(value)
    }

    /// Returns true if the set contains the value.
    pub fn contains<Q>(&self, value: &Q) -> bool
    where
        T: Borrow<Q>,
        Q: ?Sized + Ord,
    {
        self.0.contains(value)
    }

    /// Removes a value from the set. Returns true if the value existed.
    pub fn remove<Q>(&mut self, value: &Q) -> bool
    where
        T: Borrow<Q>,
        Q: ?Sized + Ord,
    {
        self.0.remove(value)
    }
}

impl<T> Extend<T> for FastSet<T>
where
    FastSetImpl<T>: Extend<T>,
{
    fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
        self.0.extend(iter);
    }
}

impl<T> FromIterator<T> for FastSet<T>
where
    FastSetImpl<T>: FromIterator<T>,
{
    fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
        Self(iter.into_iter().collect())
    }
}

impl<T> IntoIterator for FastSet<T> {
    type Item = T;
    type IntoIter = <FastSetImpl<T> as IntoIterator>::IntoIter;

    fn into_iter(self) -> Self::IntoIter {
        self.0.into_iter()
    }
}

impl<'a, T> IntoIterator for &'a FastSet<T> {
    type Item = &'a T;
    type IntoIter = <&'a FastSetImpl<T> as IntoIterator>::IntoIter;

    fn into_iter(self) -> Self::IntoIter {
        self.0.iter()
    }
}