• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

adierking / unplug / 15940344048

28 Jun 2025 04:12AM UTC coverage: 77.613%. First build
15940344048

push

github

adierking
hsd: Vertex data

0 of 109 new or added lines in 6 files covered. (0.0%)

20344 of 26212 relevant lines covered (77.61%)

1089927.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/unplug/src/hsd/array.rs
1
use super::pointer::DefaultIn;
2
use super::{Error, Node, Pointer, ReadPointer, Result};
3
use crate::common::ReadFrom;
4
use crate::hsd::pointer::ReadPointerBase;
5
use bumpalo::collections::vec::IntoIter;
6
use bumpalo::collections::Vec;
7
use bumpalo::Bump;
8
use std::ops::{Deref, DerefMut};
9

10
/// Trait for values that can be used in arrays.
11
/// Arrays (always?) end in a sentinel value, and the type needs to specify how to detect that.
12
pub trait ArrayElement {
13
    fn is_end_of_array(&self) -> bool;
14
}
15

16
impl<'a, T: Node<'a>> ArrayElement for Pointer<'a, T> {
NEW
17
    fn is_end_of_array(&self) -> bool {
×
NEW
18
        self.is_null()
×
NEW
19
    }
×
20
}
21

22
/// An array of pointers to nodes.
23
pub type PointerArray<'a, T> = Array<'a, Pointer<'a, T>>;
24

25
/// An array of values terminated by a sentinel value (e.g. null pointer).
26
/// Typically this needs to be contained in a pointer itself (TODO: make this easier).
27
#[derive(Clone, PartialEq, Eq)]
×
28
pub struct Array<'a, T: Node<'a> + ArrayElement> {
29
    elements: Vec<'a, T>,
30
}
31

32
impl<'a, T: Node<'a> + ArrayElement + std::fmt::Debug> std::fmt::Debug for Array<'a, T> {
33
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
×
34
        f.debug_list().entries(&self.elements).finish()
×
35
    }
×
36
}
37

38
impl<'a, T: Node<'a> + ArrayElement> Array<'a, T> {
39
    pub fn new_in(arena: &'a Bump) -> Self {
×
40
        Self { elements: Vec::new_in(arena) }
×
41
    }
×
42
}
43

44
impl<'a, T: Node<'a> + ArrayElement> DefaultIn<'a> for Array<'a, T> {
45
    fn default_in(arena: &'a Bump) -> Self {
×
46
        Self::new_in(arena)
×
47
    }
×
48
}
49

50
impl<'a, T: Node<'a> + ArrayElement> Deref for Array<'a, T> {
51
    type Target = [T];
52
    fn deref(&self) -> &Self::Target {
×
53
        self.elements.deref()
×
54
    }
×
55
}
56

57
impl<'a, T: Node<'a> + ArrayElement> DerefMut for Array<'a, T> {
58
    fn deref_mut(&mut self) -> &mut Self::Target {
×
59
        self.elements.deref_mut()
×
60
    }
×
61
}
62

63
impl<'a, T: Node<'a> + ArrayElement> IntoIterator for Array<'a, T> {
64
    type Item = T;
65
    type IntoIter = IntoIter<'a, T>;
66

67
    fn into_iter(self) -> Self::IntoIter {
×
68
        self.elements.into_iter()
×
69
    }
×
70
}
71

72
impl<'a, R, T> ReadFrom<R> for Array<'a, T>
73
where
74
    R: ReadPointer<'a> + ?Sized,
75
    T: Node<'a> + ArrayElement + ReadFrom<R, Error = Error>,
76
{
77
    type Error = Error;
78
    fn read_from(reader: &mut R) -> Result<Self> {
×
79
        let mut elements = Vec::new_in(reader.arena());
×
80
        loop {
NEW
81
            let value = T::read_from(reader)?;
×
NEW
82
            if value.is_end_of_array() {
×
83
                break;
×
84
            }
×
NEW
85
            elements.push(value);
×
86
        }
87
        Ok(Self { elements })
×
88
    }
×
89
}
90

91
impl<'a, T> Node<'a> for Array<'a, T> where
92
    for<'x> T: Node<'a> + ArrayElement + ReadFrom<dyn ReadPointerBase<'a> + 'x, Error = Error> + 'a
93
{
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc