smart_string/smart_string/error.rs
1use core::fmt;
2
3/// Error returned when decoding invalid UTF-16 data.
4///
5/// This is a crate-local equivalent of `std::string::FromUtf16Error`, which cannot be
6/// constructed outside of std.
7///
8/// Returned by [`SmartString::from_utf16be`], [`SmartString::from_utf16le`], and their variants.
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct Utf16DecodeError {
11 _private: (),
12}
13
14impl Utf16DecodeError {
15 pub(crate) fn new() -> Self {
16 Self { _private: () }
17 }
18}
19
20impl fmt::Display for Utf16DecodeError {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 f.write_str("invalid utf-16: lone surrogate found")
23 }
24}