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

facet-rs / facet / 15787660308

20 Jun 2025 08:54PM UTC coverage: 61.487% (+1.8%) from 59.711%
15787660308

Pull #774

github

web-flow
Merge 8921ab663 into ec93ce66e
Pull Request #774: split up Partial::end into smaller bits

147 of 165 new or added lines in 2 files covered. (89.09%)

1817 existing lines in 50 files now uncovered.

10564 of 17181 relevant lines covered (61.49%)

161.85 hits per line

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

5.45
/facet-core/src/types/def/array.rs
1
use crate::{PtrMut, ptr::PtrConst};
2

3
use super::Shape;
4

5
/// Fields for array types
6
#[derive(Clone, Copy, Debug)]
7
#[repr(C)]
8
pub struct ArrayDef<'shape> {
9
    /// vtable for interacting with the array
10
    pub vtable: &'shape ArrayVTable,
11

12
    /// shape of the items in the array
13
    pub t: &'shape Shape<'shape>,
14

15
    /// The length of the array
16
    pub n: usize,
17
}
18

19
impl<'shape> ArrayDef<'shape> {
20
    /// Returns a builder for ArrayDef
UNCOV
21
    pub const fn builder() -> ArrayDefBuilder<'shape> {
×
22
        ArrayDefBuilder::new()
×
23
    }
×
24

25
    /// Returns the shape of the items in the array
26
    pub fn t(&self) -> &'shape Shape<'shape> {
23✔
27
        self.t
23✔
28
    }
23✔
29
}
30

31
/// Builder for ArrayDef
32
pub struct ArrayDefBuilder<'shape> {
33
    vtable: Option<&'shape ArrayVTable>,
34
    t: Option<&'shape Shape<'shape>>,
35
    n: Option<usize>,
36
}
37

38
impl<'shape> ArrayDefBuilder<'shape> {
39
    /// Creates a new ArrayDefBuilder
40
    #[allow(clippy::new_without_default)]
UNCOV
41
    pub const fn new() -> Self {
×
42
        Self {
×
43
            vtable: None,
×
44
            t: None,
×
45
            n: None,
×
46
        }
×
47
    }
×
48

49
    /// Sets the vtable for the ArrayDef
UNCOV
50
    pub const fn vtable(mut self, vtable: &'shape ArrayVTable) -> Self {
×
51
        self.vtable = Some(vtable);
×
52
        self
×
53
    }
×
54

55
    /// Sets the item shape for the ArrayDef
UNCOV
56
    pub const fn t(mut self, t: &'shape Shape<'shape>) -> Self {
×
57
        self.t = Some(t);
×
58
        self
×
59
    }
×
60

61
    /// Sets the length for the ArrayDef (added method)
UNCOV
62
    pub const fn n(mut self, n: usize) -> Self {
×
63
        self.n = Some(n);
×
64
        self
×
65
    }
×
66

67
    /// Builds the ArrayDef
UNCOV
68
    pub const fn build(self) -> ArrayDef<'shape> {
×
69
        ArrayDef {
×
70
            vtable: self.vtable.unwrap(),
×
71
            t: self.t.unwrap(),
×
72
            n: self.n.unwrap(),
×
73
        }
×
74
    }
×
75
}
76

77
/// Get pointer to the data buffer of the array.
78
///
79
/// # Safety
80
///
81
/// The `array` parameter must point to aligned, initialized memory of the correct type.
82
pub type ArrayAsPtrFn = unsafe fn(array: PtrConst) -> PtrConst;
83

84
/// Get mutable pointer to the data buffer of the array.
85
///
86
/// # Safety
87
///
88
/// The `array` parameter must point to aligned, initialized memory of the correct type.
89
pub type ArrayAsMutPtrFn = unsafe fn(array: PtrMut) -> PtrMut;
90

91
/// Virtual table for an array
92
#[derive(Clone, Copy, Debug)]
93
#[repr(C)]
94
pub struct ArrayVTable {
95
    /// cf. [`ArrayAsPtrFn`]
96
    pub as_ptr: ArrayAsPtrFn,
97

98
    /// cf. [`ArrayAsMutPtrFn`]
99
    pub as_mut_ptr: ArrayAsMutPtrFn,
100
}
101

102
impl ArrayVTable {
103
    /// Returns a builder for ListVTable
UNCOV
104
    pub const fn builder() -> ArrayVTableBuilder {
×
UNCOV
105
        ArrayVTableBuilder::new()
×
106
    }
×
107
}
108

109
/// Builds a [`ArrayVTable`]
110
pub struct ArrayVTableBuilder {
111
    as_ptr_fn: Option<ArrayAsPtrFn>,
112
    as_mut_ptr_fn: Option<ArrayAsMutPtrFn>,
113
}
114

115
impl ArrayVTableBuilder {
116
    /// Creates a new [`ArrayVTableBuilder`] with all fields set to `None`.
117
    #[allow(clippy::new_without_default)]
UNCOV
118
    pub const fn new() -> Self {
×
UNCOV
119
        Self {
×
120
            as_ptr_fn: None,
×
121
            as_mut_ptr_fn: None,
×
122
        }
×
123
    }
×
124

125
    /// Sets the as_ptr field
UNCOV
126
    pub const fn as_ptr(mut self, f: ArrayAsPtrFn) -> Self {
×
UNCOV
127
        self.as_ptr_fn = Some(f);
×
128
        self
×
129
    }
×
130

131
    /// Sets the as_mut_ptr field
UNCOV
132
    pub const fn as_mut_ptr(mut self, f: ArrayAsMutPtrFn) -> Self {
×
UNCOV
133
        self.as_mut_ptr_fn = Some(f);
×
134
        self
×
135
    }
×
136

137
    /// Builds the [`ArrayVTable`] from the current state of the builder.
138
    ///
139
    /// # Panics
140
    ///
141
    /// This method will panic if any of the required fields are `None`.
UNCOV
142
    pub const fn build(self) -> ArrayVTable {
×
UNCOV
143
        ArrayVTable {
×
144
            as_ptr: self.as_ptr_fn.unwrap(),
×
145
            as_mut_ptr: self.as_mut_ptr_fn.unwrap(),
×
146
        }
×
147
    }
×
148
}
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