lean_string/errors/from_utf16_error.rs
1use core::{error::Error, fmt};
2
3/// An error if the conversion from a sequence of UTF-16 code units to a [`LeanString`] fails due
4/// to invalid UTF-16 code unit sequences.
5///
6/// [`LeanString`]: crate::LeanString
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub struct FromUtf16Error;
9
10impl Error for FromUtf16Error {}
11
12impl fmt::Display for FromUtf16Error {
13 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14 write!(f, "invalid utf-16 sequence")
15 }
16}