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

facet-rs / facet / 16482855623

23 Jul 2025 10:08PM UTC coverage: 58.447% (-0.2%) from 58.68%
16482855623

Pull #855

github

web-flow
Merge dca4c2302 into 5e8e214d1
Pull Request #855: wip: Remove 'shape lifetime

400 of 572 new or added lines in 70 files covered. (69.93%)

3 existing lines in 3 files now uncovered.

11939 of 20427 relevant lines covered (58.45%)

120.58 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 {
9
    /// vtable for interacting with the array
10
    pub vtable: &'static ArrayVTable,
11

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

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

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

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

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

38
impl ArrayDefBuilder {
39
    /// Creates a new ArrayDefBuilder
40
    #[allow(clippy::new_without_default)]
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
NEW
50
    pub const fn vtable(mut self, vtable: &'static ArrayVTable) -> Self {
×
51
        self.vtable = Some(vtable);
×
52
        self
×
53
    }
×
54

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

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

67
    /// Builds the ArrayDef
NEW
68
    pub const fn build(self) -> ArrayDef {
×
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
104
    pub const fn builder() -> ArrayVTableBuilder {
×
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)]
118
    pub const fn new() -> Self {
×
119
        Self {
×
120
            as_ptr_fn: None,
×
121
            as_mut_ptr_fn: None,
×
122
        }
×
123
    }
×
124

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

131
    /// Sets the as_mut_ptr field
132
    pub const fn as_mut_ptr(mut self, f: ArrayAsMutPtrFn) -> Self {
×
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`.
142
    pub const fn build(self) -> ArrayVTable {
×
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