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

facet-rs / facet / 16482665288

23 Jul 2025 09:56PM UTC coverage: 58.441% (-0.2%) from 58.68%
16482665288

Pull #855

github

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

399 of 571 new or added lines in 70 files covered. (69.88%)

3 existing lines in 3 files now uncovered.

11939 of 20429 relevant lines covered (58.44%)

120.56 hits per line

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

0.0
/facet-core/src/types/def/function.rs
1
use crate::Shape;
2

3
/// Common fields for function pointer types
4
#[derive(Clone, Copy, Debug)]
5
#[repr(C)]
6
pub struct FunctionPointerDef {
7
    /// The calling abi of the function pointer
8
    pub abi: FunctionAbi,
9

10
    /// All parameter types, in declaration order
11
    pub parameters: &'static [fn() -> &'static Shape],
12

13
    /// The return type
14
    pub return_type: fn() -> &'static Shape,
15
}
16

17
/// The calling ABI of a function pointer
18
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default)]
19
#[repr(C)]
20
pub enum FunctionAbi {
21
    /// C ABI
22
    C,
23

24
    /// Rust ABI
25
    #[default]
26
    Rust,
27

28
    /// An unknown ABI
29
    Unknown,
30
}
31
impl FunctionAbi {
32
    /// Returns the string in `extern "abi-string"` if not [`FunctionAbi::Unknown`].
33
    pub fn as_abi_str(&self) -> Option<&str> {
×
34
        match self {
×
35
            FunctionAbi::C => Some("C"),
×
36
            FunctionAbi::Rust => Some("Rust"),
×
37
            FunctionAbi::Unknown => None,
×
38
        }
39
    }
×
40
}
41

42
impl FunctionPointerDef {
43
    /// Returns a builder for FunctionPointerDef
44
    pub const fn builder() -> FunctionPointerDefBuilder {
×
45
        FunctionPointerDefBuilder::new()
×
46
    }
×
47
}
48

49
/// Builder for FunctionPointerDef
50
pub struct FunctionPointerDefBuilder {
51
    abi: Option<FunctionAbi>,
52
    parameters: &'static [fn() -> &'static Shape],
53
    return_type: Option<fn() -> &'static Shape>,
54
}
55

56
impl FunctionPointerDefBuilder {
57
    /// Creates a new FunctionPointerDefBuilder
58
    #[allow(clippy::new_without_default)]
59
    pub const fn new() -> Self {
×
60
        Self {
×
61
            parameters: &[],
×
62
            abi: None,
×
63
            return_type: None,
×
64
        }
×
65
    }
×
66

67
    /// Sets the abi for the FunctionPointerDef
68
    pub const fn abi(mut self, abi: FunctionAbi) -> Self {
×
69
        self.abi = Some(abi);
×
70
        self
×
71
    }
×
72

73
    /// Sets the parameters for the FunctionPointerDef
NEW
74
    pub const fn parameter_types(mut self, parameters: &'static [fn() -> &'static Shape]) -> Self {
×
75
        self.parameters = parameters;
×
76
        self
×
77
    }
×
78

79
    /// Sets the return type for the FunctionPointerDef
NEW
80
    pub const fn return_type(mut self, ty: fn() -> &'static Shape) -> Self {
×
81
        self.return_type = Some(ty);
×
82
        self
×
83
    }
×
84

85
    /// Builds the FunctionPointerDef
86
    pub const fn build(self) -> FunctionPointerDef {
×
87
        FunctionPointerDef {
×
88
            parameters: self.parameters,
×
89
            return_type: self.return_type.unwrap(),
×
90
            abi: self.abi.unwrap(),
×
91
        }
×
92
    }
×
93
}
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