зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1513350 - Add a Display impl to nsresult, r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D24754 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
14d68ff6e0
Коммит
d853d5bd7f
|
@ -1,13 +1,15 @@
|
|||
extern crate nsstring;
|
||||
|
||||
use nsstring::{nsCString, nsACString};
|
||||
use nsstring::{nsACString, nsCString};
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
|
||||
/// The type of errors in gecko. Uses a newtype to provide additional type
|
||||
/// safety in Rust and #[repr(transparent)] to ensure the same representation
|
||||
/// as the C++ equivalent.
|
||||
#[repr(transparent)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub struct nsresult(pub u32);
|
||||
|
||||
impl nsresult {
|
||||
|
@ -38,6 +40,20 @@ impl nsresult {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for nsresult {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.error_name())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for nsresult {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.error_name())
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for nsresult {}
|
||||
|
||||
extern "C" {
|
||||
fn Gecko_GetErrorName(rv: nsresult, cstr: *mut nsACString);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче