1#[cfg(not(no_serde_derive))]
2pub mod de;
3#[cfg(not(no_serde_derive))]
4pub mod ser;
56// FIXME: #[cfg(doctest)] once https://github.com/rust-lang/rust/issues/67295 is fixed.
7pub mod doc;
89pub use crate::lib::clone::Clone;
10pub use crate::lib::convert::{From, Into};
11pub use crate::lib::default::Default;
12pub use crate::lib::fmt::{self, Formatter};
13pub use crate::lib::marker::PhantomData;
14pub use crate::lib::option::Option::{self, None, Some};
15pub use crate::lib::ptr;
16pub use crate::lib::result::Result::{self, Err, Ok};
1718pub use self::string::from_utf8_lossy;
1920#[cfg(any(feature = "alloc", feature = "std"))]
21pub use crate::lib::{ToString, Vec};
2223#[cfg(not(no_core_try_from))]
24pub use crate::lib::convert::TryFrom;
2526mod string {
27use crate::lib::*;
2829#[cfg(any(feature = "std", feature = "alloc"))]
30pub fn from_utf8_lossy(bytes: &[u8]) -> Cow<str> {
31 String::from_utf8_lossy(bytes)
32 }
3334// The generated code calls this like:
35 //
36 // let value = &_serde::__private::from_utf8_lossy(bytes);
37 // Err(_serde::de::Error::unknown_variant(value, VARIANTS))
38 //
39 // so it is okay for the return type to be different from the std case as long
40 // as the above works.
41#[cfg(not(any(feature = "std", feature = "alloc")))]
42pub fn from_utf8_lossy(bytes: &[u8]) -> &str {
43// Three unicode replacement characters if it fails. They look like a
44 // white-on-black question mark. The user will recognize it as invalid
45 // UTF-8.
46str::from_utf8(bytes).unwrap_or("\u{fffd}\u{fffd}\u{fffd}")
47 }
48}