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

facet-rs / facet / 14439358497

14 Apr 2025 06:53AM UTC coverage: 21.3% (-10.3%) from 31.623%
14439358497

push

github

web-flow
Rewrite facet-reflect for safety (#188)

* Rewrite facet-reflect for safety

* WIP invariants support

* WIP invariants

* WIP invariants

* Invariant validation works!

* Fix derive for enums

* Start documenting new reflect

* Comment out other workspace members for now.

* Get rid of warnings, tests pass again for now

* Update main readme

* Take care of Peek

* Yay no more errors in peek

* Most of Peek is back.

* PeekOption tests

* fix enum test

* Refactor enum field access methods

Replace field name-based access with index-based access and provide
a field_by_name helper. Remove redundant tuple_field method in favor
of a unified field access approach that works for both tuple and struct
variants.

* PeekList tests

* no clippy warnings

* Avoid clippy --all-features locally, which trashes target/

* Add map tests

* Some smart pointer tests

* Avoid cycles with delayed/fns

* Fix doc errors, rename impls to different file paths

* Option Debug

* f64 implements PartialCmp

* Replace as_ref with get in all unsafe blocks.

* When putting into a PokeValueUninit, require : 'mem

cf. #190 / https://github.com/facet-rs/facet/issues/190#issuecomment-2799860033

* Document facet-ansi

* Light ui test harness

* Make sure the facet-ansi tests can pass.

* Port facet-pretty over

* facet-pretty good except indentation, ofc

* Fix doc comment formatting

* Port libc sample test

* Uncomment scalar test

* Re-add smart pointer tests

* WIP HeapVal wrapper

* Wip HeapValue wrapper

* API design is hard okay

* Oh now poke tests are ANGRY

* Still HeapAlloc'ing

* More HeapVal

* whew 4

* Mhh slots are gonna be hard to get right

* well some things are failing BADLY

* no problems huh

* 2 failing

* mhmh

* mh

* I don't get it

* Test tree

* Try out a tree

* Cannot move out of huh, where have I heard that before

* Tree => builder

* New builder API coming along

* there we have it again — an invariant violation

* OMG IT WAS MEMCPY ALL ALONG

* Ah, ... (continued)

518 of 1109 new or added lines in 45 files covered. (46.71%)

642 existing lines in 17 files now uncovered.

1278 of 6000 relevant lines covered (21.3%)

12.01 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)
NEW
18
                    .weak(|| <alloc::sync::Weak<T> as Facet>::SHAPE)
×
19
                    .vtable(
20
                        &const {
21
                            SmartPointerVTable::builder()
NEW
22
                                .borrow_fn(|opaque| {
×
NEW
23
                                    let ptr = Self::as_ptr(unsafe { opaque.get() });
×
NEW
24
                                    OpaqueConst::new(ptr)
×
25
                                })
NEW
26
                                .new_into_fn(|this, ptr| {
×
NEW
27
                                    let t = unsafe { ptr.read::<T>() };
×
NEW
28
                                    let arc = alloc::sync::Arc::new(t);
×
NEW
29
                                    unsafe { this.put(arc) }
×
30
                                })
NEW
31
                                .downgrade_fn(|strong, weak| unsafe {
×
NEW
32
                                    weak.put(alloc::sync::Arc::downgrade(strong.get::<Self>()))
×
33
                                })
34
                                .build()
35
                        },
36
                    )
37
                    .build(),
38
            ))
NEW
39
            .vtable(value_vtable!(alloc::sync::Arc<T>, |f, _opts| write!(
×
NEW
40
                f,
×
NEW
41
                "Arc"
×
42
            )))
43
            .build()
44
    };
45
}
46

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