From 7b1dd52ad1678b111f1ffa88df7472db99d5f8f9 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Thu, 20 Nov 2025 10:18:48 +0000 Subject: [PATCH] winit-core/ime: implement `Error` for `ImeSurroundingTextError` --- winit-core/src/window.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/winit-core/src/window.rs b/winit-core/src/window.rs index aa7f17100..cfca86280 100644 --- a/winit-core/src/window.rs +++ b/winit-core/src/window.rs @@ -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))]