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

facet-rs / facet / 14452385182

14 Apr 2025 05:56PM UTC coverage: 29.49% (+3.1%) from 26.376%
14452385182

Pull #213

github

web-flow
Merge c7ac5fb03 into 1fd193c0d
Pull Request #213: WIP: resurrect facet-json

239 of 648 new or added lines in 14 files covered. (36.88%)

5 existing lines in 3 files now uncovered.

1908 of 6470 relevant lines covered (29.49%)

24.52 hits per line

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

0.0
/facet-core/src/impls_alloc/smartptr.rs
1
use core::alloc::Layout;
2

3
use crate::{
4
    ConstTypeId, Def, Facet, KnownSmartPointer, OpaqueConst, SmartPointerDef, SmartPointerFlags,
5
    SmartPointerVTable, value_vtable,
6
};
7

8
unsafe impl<T: Facet> Facet for alloc::sync::Arc<T> {
9
    const SHAPE: &'static crate::Shape = &const {
10
        crate::Shape::builder()
11
            .id(ConstTypeId::of::<Self>())
12
            .layout(Layout::new::<Self>())
13
            .def(Def::SmartPointer(
14
                SmartPointerDef::builder()
15
                    .pointee(T::SHAPE)
16
                    .flags(SmartPointerFlags::ATOMIC)
17
                    .known(KnownSmartPointer::Arc)
18
                    .weak(|| <alloc::sync::Weak<T> as Facet>::SHAPE)
×
19
                    .vtable(
20
                        &const {
21
                            SmartPointerVTable::builder()
22
                                .borrow_fn(|opaque| {
×
23
                                    let ptr = Self::as_ptr(unsafe { opaque.get() });
×
24
                                    OpaqueConst::new(ptr)
×
25
                                })
26
                                .new_into_fn(|this, ptr| {
×
27
                                    let t = unsafe { ptr.read::<T>() };
×
28
                                    let arc = alloc::sync::Arc::new(t);
×
29
                                    unsafe { this.put(arc) }
×
30
                                })
31
                                .downgrade_fn(|strong, weak| unsafe {
×
32
                                    weak.put(alloc::sync::Arc::downgrade(strong.get::<Self>()))
×
33
                                })
34
                                .build()
35
                        },
36
                    )
37
                    .build(),
38
            ))
39
            .vtable(value_vtable!(alloc::sync::Arc<T>, |f, _opts| write!(
×
40
                f,
×
41
                "Arc"
×
42
            )))
43
            .build()
44
    };
45
}
46

47
unsafe impl<T: Facet> Facet for alloc::sync::Weak<T> {
48
    const SHAPE: &'static crate::Shape = &const {
49
        crate::Shape::builder()
50
            .id(ConstTypeId::of::<Self>())
51
            .layout(Layout::new::<Self>())
52
            .def(Def::SmartPointer(
53
                SmartPointerDef::builder()
54
                    .pointee(T::SHAPE)
55
                    .flags(SmartPointerFlags::ATOMIC.union(SmartPointerFlags::WEAK))
56
                    .known(KnownSmartPointer::ArcWeak)
UNCOV
57
                    .strong(|| <alloc::sync::Arc<T> as Facet>::SHAPE)
×
58
                    .vtable(
59
                        &const {
60
                            SmartPointerVTable::builder()
UNCOV
61
                                .upgrade_into_fn(|weak, strong| unsafe {
×
62
                                    Some(strong.put(weak.get::<Self>().upgrade()?))
×
63
                                })
64
                                .build()
65
                        },
66
                    )
67
                    .build(),
68
            ))
UNCOV
69
            .vtable(value_vtable!(alloc::sync::Arc<T>, |f, _opts| write!(
×
70
                f,
×
71
                "Arc"
×
72
            )))
73
            .build()
74
    };
75
}
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