winit-core/ime: implement Error for ImeSurroundingTextError

This commit is contained in:
Diggory Hardy
2025-11-20 10:18:48 +00:00
committed by GitHub
parent 6a46610632
commit 7b1dd52ad1

View File

@@ -1691,6 +1691,22 @@ pub enum ImeSurroundingTextError {
AnchorBadPosition,
}
impl fmt::Display for ImeSurroundingTextError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ImeSurroundingTextError::TextTooLong => write!(f, "text exceeds maximum length"),
ImeSurroundingTextError::CursorBadPosition => {
write!(f, "cursor is not at a valid text index")
},
ImeSurroundingTextError::AnchorBadPosition => {
write!(f, "anchor is not at a valid text index")
},
}
}
}
impl std::error::Error for ImeSurroundingTextError {}
/// Defines the text surrounding the caret
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]