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

facet-rs / facet / 15200164445

23 May 2025 01:21AM UTC coverage: 57.288% (+0.1%) from 57.185%
15200164445

Pull #666

github

web-flow
Merge 4232978c5 into 4b41e5c8a
Pull Request #666: Add indirection to vtable fns to fix cyclic types

715 of 1482 new or added lines in 34 files covered. (48.25%)

14 existing lines in 5 files now uncovered.

9747 of 17014 relevant lines covered (57.29%)

132.73 hits per line

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

60.26
/facet-core/src/impls_core/slice.rs
1
use crate::*;
2

3
unsafe impl<'a, T> Facet<'a> for [T]
4
where
5
    T: Facet<'a>,
6
{
7
    const VTABLE: &'static ValueVTable = &const {
8
        ValueVTable::builder_unsized::<Self>()
9
            .type_name(|f, opts| {
7✔
10
                if let Some(opts) = opts.for_children() {
7✔
11
                    write!(f, "[")?;
7✔
12
                    (T::SHAPE.vtable.type_name)(f, opts)?;
7✔
13
                    write!(f, "]")
7✔
14
                } else {
15
                    write!(f, "[⋯]")
×
16
                }
17
            })
7✔
18
            .marker_traits(|| T::SHAPE.vtable.marker_traits())
4✔
19
            .debug(|| {
28✔
20
                if (T::SHAPE.vtable.debug)().is_some() {
28✔
21
                    Some(|value, f| {
12✔
22
                        write!(f, "[")?;
12✔
23
                        for (i, item) in value.iter().enumerate() {
30✔
24
                            if i > 0 {
30✔
25
                                write!(f, ", ")?;
18✔
26
                            }
12✔
27
                            (<VTableView<T>>::of().debug().unwrap())(item, f)?;
30✔
28
                        }
29
                        write!(f, "]")
12✔
30
                    })
12✔
31
                } else {
NEW
32
                    None
×
33
                }
34
            })
28✔
35
            .eq(|| {
6✔
36
                if (T::SHAPE.vtable.eq)().is_some() {
6✔
37
                    Some(|a, b| {
2✔
38
                        if a.len() != b.len() {
2✔
NEW
39
                            return false;
×
40
                        }
2✔
41
                        for (x, y) in a.iter().zip(b.iter()) {
2✔
42
                            if !(<VTableView<T>>::of().eq().unwrap())(x, y) {
2✔
43
                                return false;
2✔
NEW
44
                            }
×
45
                        }
NEW
46
                        true
×
47
                    })
2✔
48
                } else {
NEW
49
                    None
×
50
                }
51
            })
6✔
52
            .partial_ord(|| {
4✔
53
                if (T::SHAPE.vtable.partial_ord)().is_some() {
4✔
54
                    Some(|a, b| {
2✔
55
                        for (x, y) in a.iter().zip(b.iter()) {
2✔
56
                            let ord = (<VTableView<T>>::of().partial_ord().unwrap())(x, y);
2✔
57
                            match ord {
2✔
NEW
58
                                Some(core::cmp::Ordering::Equal) => continue,
×
59
                                Some(order) => return Some(order),
2✔
NEW
60
                                None => return None,
×
61
                            }
62
                        }
NEW
63
                        a.len().partial_cmp(&b.len())
×
64
                    })
2✔
65
                } else {
NEW
66
                    None
×
67
                }
68
            })
4✔
69
            .ord(|| {
2✔
70
                if (T::SHAPE.vtable.ord)().is_some() {
2✔
NEW
71
                    Some(|a, b| {
×
NEW
72
                        for (x, y) in a.iter().zip(b.iter()) {
×
NEW
73
                            let ord = (<VTableView<T>>::of().ord().unwrap())(x, y);
×
NEW
74
                            if ord != core::cmp::Ordering::Equal {
×
NEW
75
                                return ord;
×
NEW
76
                            }
×
77
                        }
NEW
78
                        a.len().cmp(&b.len())
×
NEW
79
                    })
×
80
                } else {
NEW
81
                    None
×
82
                }
83
            })
2✔
NEW
84
            .hash(|| {
×
NEW
85
                if (T::SHAPE.vtable.hash)().is_some() {
×
NEW
86
                    Some(|value, state, hasher| {
×
NEW
87
                        for item in value.iter() {
×
NEW
88
                            (<VTableView<T>>::of().hash().unwrap())(item, state, hasher);
×
NEW
89
                        }
×
NEW
90
                    })
×
91
                } else {
NEW
92
                    None
×
93
                }
NEW
94
            })
×
95
            .build()
96
    };
97

98
    const SHAPE: &'static Shape<'static> = &const {
99
        Shape::builder_for_unsized::<Self>()
100
            .type_params(&[TypeParam {
101
                name: "T",
102
                shape: || T::SHAPE,
103
            }])
104
            .ty(Type::Sequence(SequenceType::Slice(SliceType {
105
                t: T::SHAPE,
106
            })))
107
            .def(Def::Slice(
108
                SliceDef::builder()
109
                    .vtable(
110
                        &const {
111
                            SliceVTable::builder()
112
                                .len(|ptr| unsafe {
113
                                    let slice = ptr.get::<&[T]>();
13✔
114
                                    slice.len()
13✔
115
                                })
13✔
116
                                .as_ptr(|ptr| unsafe {
117
                                    let slice = ptr.get::<&[T]>();
11✔
118
                                    PtrConst::new(slice.as_ptr())
11✔
119
                                })
11✔
120
                                .as_mut_ptr(|ptr| unsafe {
121
                                    let slice = ptr.as_mut::<&mut [T]>();
×
122
                                    PtrMut::new(slice.as_mut_ptr())
×
123
                                })
×
124
                                .build()
125
                        },
126
                    )
127
                    .t(T::SHAPE)
128
                    .build(),
129
            ))
130
            .build()
131
    };
132
}
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