mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
icu: Derive PartialEq and Eq
Also fixes a TODO about making comparisons better.
This commit is contained in:
parent
4bfd85556d
commit
e85b4260bd
1 changed files with 1 additions and 17 deletions
|
@ -6,7 +6,7 @@ use crate::bindings::{icu_error_code_to_name, UErrorCode};
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
|
||||||
/// Errors this library can produce.
|
/// Errors this library can produce.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error produced by one of the ICU functions.
|
/// An error produced by one of the ICU functions.
|
||||||
Icu(String),
|
Icu(String),
|
||||||
|
@ -24,22 +24,6 @@ pub enum Error {
|
||||||
TooLong,
|
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 {
|
impl Error {
|
||||||
pub(crate) fn from_icu_code(err: UErrorCode) -> Error {
|
pub(crate) fn from_icu_code(err: UErrorCode) -> Error {
|
||||||
let ptr = unsafe { icu_error_code_to_name(err) };
|
let ptr = unsafe { icu_error_code_to_name(err) };
|
||||||
|
|
Loading…
Reference in a new issue