use core::{error::Error, fmt};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct FromUtf16Error {
pub(crate) kind: FromUtf16ErrorKind,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub(crate) enum FromUtf16ErrorKind {
LoneSurrogate,
OddBytes,
}
impl Error for FromUtf16Error {}
impl fmt::Display for FromUtf16Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.kind {
FromUtf16ErrorKind::LoneSurrogate => "invalid utf-16: lone surrogate found",
FromUtf16ErrorKind::OddBytes => "invalid utf-16: odd number of bytes",
}
.fmt(f)
}
}