Coverage Report

Created: 2025-10-29 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.152/src/private/mod.rs
Line
Count
Source
1
#[cfg(not(no_serde_derive))]
2
pub mod de;
3
#[cfg(not(no_serde_derive))]
4
pub mod ser;
5
6
pub mod size_hint;
7
8
// FIXME: #[cfg(doctest)] once https://github.com/rust-lang/rust/issues/67295 is fixed.
9
pub mod doc;
10
11
pub use lib::clone::Clone;
12
pub use lib::convert::{From, Into};
13
pub use lib::default::Default;
14
pub use lib::fmt::{self, Formatter};
15
pub use lib::marker::PhantomData;
16
pub use lib::option::Option::{self, None, Some};
17
pub use lib::ptr;
18
pub use lib::result::Result::{self, Err, Ok};
19
20
pub use self::string::from_utf8_lossy;
21
22
#[cfg(any(feature = "alloc", feature = "std"))]
23
pub use lib::{ToString, Vec};
24
25
#[cfg(not(no_core_try_from))]
26
pub use lib::convert::TryFrom;
27
28
mod string {
29
    use lib::*;
30
31
    #[cfg(any(feature = "std", feature = "alloc"))]
32
0
    pub fn from_utf8_lossy(bytes: &[u8]) -> Cow<str> {
33
0
        String::from_utf8_lossy(bytes)
34
0
    }
35
36
    // The generated code calls this like:
37
    //
38
    //     let value = &_serde::__private::from_utf8_lossy(bytes);
39
    //     Err(_serde::de::Error::unknown_variant(value, VARIANTS))
40
    //
41
    // so it is okay for the return type to be different from the std case as long
42
    // as the above works.
43
    #[cfg(not(any(feature = "std", feature = "alloc")))]
44
    pub fn from_utf8_lossy(bytes: &[u8]) -> &str {
45
        // Three unicode replacement characters if it fails. They look like a
46
        // white-on-black question mark. The user will recognize it as invalid
47
        // UTF-8.
48
        str::from_utf8(bytes).unwrap_or("\u{fffd}\u{fffd}\u{fffd}")
49
    }
50
}