From e85b4260bda591aa3263bc437955a91bc2eb50f7 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 20 Sep 2022 19:13:55 +0200 Subject: [PATCH] icu: Derive PartialEq and Eq Also fixes a TODO about making comparisons better. --- icu/src/error.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/icu/src/error.rs b/icu/src/error.rs index b012f56..af7f42e 100644 --- a/icu/src/error.rs +++ b/icu/src/error.rs @@ -6,7 +6,7 @@ use crate::bindings::{icu_error_code_to_name, UErrorCode}; use std::ffi::CStr; /// Errors this library can produce. -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq)] pub enum Error { /// An error produced by one of the ICU functions. Icu(String), @@ -24,22 +24,6 @@ pub enum Error { TooLong, } -impl PartialEq for Error { - fn eq(&self, other: &Self) -> bool { - match (self, other) { - (Error::Icu(s1), Error::Icu(s2)) => s1 == s2, - (Error::Idna(s1), Error::Idna(s2)) => s1 == s2, - // TODO: compare by something here? - (Error::Utf8(_s1), Error::Utf8(_s2)) => true, - (Error::Utf16(_s1), Error::Utf16(_s2)) => true, - (Error::TooLong, Error::TooLong) => true, - _ => false, - } - } -} - -impl Eq for Error {} - impl Error { pub(crate) fn from_icu_code(err: UErrorCode) -> Error { let ptr = unsafe { icu_error_code_to_name(err) };