Coverage Report

Created: 2026-11-12 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/asn1-rs-0.7.1/src/tostatic.rs
Line
Count
Source
1
use alloc::borrow::Cow;
2
use alloc::string::ToString;
3
4
/// Common trait for objects that can be transformed to a `'static` version of `self`
5
pub trait ToStatic {
6
    type Owned: 'static;
7
    fn to_static(&self) -> Self::Owned;
8
}
9
10
impl ToStatic for Cow<'_, str> {
11
    type Owned = Cow<'static, str>;
12
36.6k
    fn to_static(&self) -> <Self as ToStatic>::Owned {
13
36.6k
        Cow::Owned(self.to_string())
14
36.6k
    }
<alloc::borrow::Cow<str> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
12
9.86k
    fn to_static(&self) -> <Self as ToStatic>::Owned {
13
9.86k
        Cow::Owned(self.to_string())
14
9.86k
    }
<alloc::borrow::Cow<str> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
12
26.7k
    fn to_static(&self) -> <Self as ToStatic>::Owned {
13
26.7k
        Cow::Owned(self.to_string())
14
26.7k
    }
15
}
16
17
impl ToStatic for Cow<'_, [u8]> {
18
    type Owned = Cow<'static, [u8]>;
19
735
    fn to_static(&self) -> <Self as ToStatic>::Owned {
20
735
        Cow::Owned(self.to_vec())
21
735
    }
<alloc::borrow::Cow<[u8]> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
19
12
    fn to_static(&self) -> <Self as ToStatic>::Owned {
20
12
        Cow::Owned(self.to_vec())
21
12
    }
<alloc::borrow::Cow<[u8]> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
19
723
    fn to_static(&self) -> <Self as ToStatic>::Owned {
20
723
        Cow::Owned(self.to_vec())
21
723
    }
22
}
23
24
macro_rules! impl_tostatic_primitive {
25
    ($t:ty) => {
26
        impl ToStatic for $t {
27
            type Owned = $t;
28
37.9k
            fn to_static(&self) -> <Self as ToStatic>::Owned {
29
37.9k
                self.clone()
30
37.9k
            }
<u8 as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
28
135
            fn to_static(&self) -> <Self as ToStatic>::Owned {
29
135
                self.clone()
30
135
            }
<u32 as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
28
9.84k
            fn to_static(&self) -> <Self as ToStatic>::Owned {
29
9.84k
                self.clone()
30
9.84k
            }
<bool as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
28
1
            fn to_static(&self) -> <Self as ToStatic>::Owned {
29
1
                self.clone()
30
1
            }
Unexecuted instantiation: <alloc::string::String as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i8 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i16 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i32 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i64 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i128 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <isize as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <u16 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <u64 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <u128 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <usize as asn1_rs::tostatic::ToStatic>::to_static
<u8 as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
28
745
            fn to_static(&self) -> <Self as ToStatic>::Owned {
29
745
                self.clone()
30
745
            }
<u32 as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
28
27.1k
            fn to_static(&self) -> <Self as ToStatic>::Owned {
29
27.1k
                self.clone()
30
27.1k
            }
<bool as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
28
69
            fn to_static(&self) -> <Self as ToStatic>::Owned {
29
69
                self.clone()
30
69
            }
Unexecuted instantiation: <alloc::string::String as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i8 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i16 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i32 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i64 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <i128 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <isize as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <u16 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <u64 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <u128 as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <usize as asn1_rs::tostatic::ToStatic>::to_static
31
        }
32
    };
33
    ($t:ty => $to:ty, $closure:expr) => {
34
        impl ToStatic for $t {
35
            type Owned = $to;
36
0
            fn to_static(&self) -> <Self as ToStatic>::Owned {
37
0
                let f: &dyn Fn(&Self) -> $to = &$closure;
38
0
                f(self)
39
0
            }
Unexecuted instantiation: <str as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <str as asn1_rs::tostatic::ToStatic>::to_static
40
        }
41
    };
42
    (I $($types: ty)+) => {
43
        $(
44
            impl_tostatic_primitive!($types);
45
        )*
46
    };
47
}
48
49
impl_tostatic_primitive!(bool);
50
impl_tostatic_primitive!(I i8 i16 i32 i64 i128 isize);
51
impl_tostatic_primitive!(I u8 u16 u32 u64 u128 usize);
52
53
impl<T> ToStatic for &'_ T
54
where
55
    T: ToStatic,
56
{
57
    type Owned = T::Owned;
58
59
0
    fn to_static(&self) -> Self::Owned {
60
0
        (*self).to_static()
61
0
    }
Unexecuted instantiation: <&_ as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <&_ as asn1_rs::tostatic::ToStatic>::to_static
62
}
63
64
impl<T> ToStatic for Option<T>
65
where
66
    T: ToStatic,
67
{
68
    type Owned = Option<T::Owned>;
69
70
40.4k
    fn to_static(&self) -> Self::Owned {
71
40.4k
        self.as_ref().map(ToStatic::to_static)
72
40.4k
    }
<core::option::Option<alloc::vec::Vec<ldap_parser::ldap::Control>> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
9.73k
    fn to_static(&self) -> Self::Owned {
71
9.73k
        self.as_ref().map(ToStatic::to_static)
72
9.73k
    }
<core::option::Option<alloc::borrow::Cow<[u8]>> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
138
    fn to_static(&self) -> Self::Owned {
71
138
        self.as_ref().map(ToStatic::to_static)
72
138
    }
<core::option::Option<ldap_parser::ldap::LdapDN> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
1
    fn to_static(&self) -> Self::Owned {
71
1
        self.as_ref().map(ToStatic::to_static)
72
1
    }
<core::option::Option<ldap_parser::ldap::LdapOID> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
8
    fn to_static(&self) -> Self::Owned {
71
8
        self.as_ref().map(ToStatic::to_static)
72
8
    }
Unexecuted instantiation: <core::option::Option<ldap_parser::ldap::LdapString> as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <core::option::Option<ldap_parser::filter::AttributeDescription> as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <core::option::Option<bool> as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <core::option::Option<_> as asn1_rs::tostatic::ToStatic>::to_static
<core::option::Option<alloc::vec::Vec<ldap_parser::ldap::Control>> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
19.9k
    fn to_static(&self) -> Self::Owned {
71
19.9k
        self.as_ref().map(ToStatic::to_static)
72
19.9k
    }
<core::option::Option<alloc::borrow::Cow<[u8]>> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
7.76k
    fn to_static(&self) -> Self::Owned {
71
7.76k
        self.as_ref().map(ToStatic::to_static)
72
7.76k
    }
<core::option::Option<ldap_parser::ldap::LdapDN> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
4
    fn to_static(&self) -> Self::Owned {
71
4
        self.as_ref().map(ToStatic::to_static)
72
4
    }
<core::option::Option<ldap_parser::ldap::LdapOID> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
2.85k
    fn to_static(&self) -> Self::Owned {
71
2.85k
        self.as_ref().map(ToStatic::to_static)
72
2.85k
    }
<core::option::Option<ldap_parser::ldap::LdapString> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
14
    fn to_static(&self) -> Self::Owned {
71
14
        self.as_ref().map(ToStatic::to_static)
72
14
    }
<core::option::Option<ldap_parser::filter::AttributeDescription> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
14
    fn to_static(&self) -> Self::Owned {
71
14
        self.as_ref().map(ToStatic::to_static)
72
14
    }
<core::option::Option<bool> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
70
14
    fn to_static(&self) -> Self::Owned {
71
14
        self.as_ref().map(ToStatic::to_static)
72
14
    }
Unexecuted instantiation: <core::option::Option<_> as asn1_rs::tostatic::ToStatic>::to_static
73
}
74
75
#[cfg(feature = "std")]
76
const _: () = {
77
    impl_tostatic_primitive!(I String);
78
0
    impl_tostatic_primitive!(str => String, |s| s.to_string());
Unexecuted instantiation: <str as asn1_rs::tostatic::ToStatic>::to_static::{closure#0}
Unexecuted instantiation: <str as asn1_rs::tostatic::ToStatic>::to_static::{closure#0}
79
80
    impl<T> ToStatic for Box<T>
81
    where
82
        T: ToStatic,
83
    {
84
        type Owned = Box<T::Owned>;
85
86
10
        fn to_static(&self) -> Self::Owned {
87
10
            Box::new(self.as_ref().to_static())
88
10
        }
Unexecuted instantiation: <alloc::boxed::Box<ldap_parser::filter::Filter> as asn1_rs::tostatic::ToStatic>::to_static
Unexecuted instantiation: <alloc::boxed::Box<_> as asn1_rs::tostatic::ToStatic>::to_static
<alloc::boxed::Box<ldap_parser::filter::Filter> as asn1_rs::tostatic::ToStatic>::to_static
Line
Count
Source
86
10
        fn to_static(&self) -> Self::Owned {
87
10
            Box::new(self.as_ref().to_static())
88
10
        }
Unexecuted instantiation: <alloc::boxed::Box<_> as asn1_rs::tostatic::ToStatic>::to_static
89
    }
90
};