diff options
author | David Tolnay <dtolnay@gmail.com> | 2020-08-30 13:07:10 -0700 |
---|---|---|
committer | David Tolnay <dtolnay@gmail.com> | 2020-08-30 13:07:12 -0700 |
commit | 507bdc1905e3739c0595e5adaa7f794339735053 (patch) | |
tree | 1b3236c9b7df9cedc6d9c65db3bfbd999910a48d /gen/lib/src/error.rs | |
parent | f5c72266f7eedfaba8f0dc11cb91a6fba90fdfb1 (diff) | |
download | cxx-507bdc1905e3739c0595e5adaa7f794339735053.tar.gz |
Store cxx-gen error as braced struct
This appears more sympathetically in rustdoc as:
pub struct Error { /* fields omitted */ }
rather than:
pub struct Error(_);
Diffstat (limited to 'gen/lib/src/error.rs')
-rw-r--r-- | gen/lib/src/error.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gen/lib/src/error.rs b/gen/lib/src/error.rs index 3cf1e625..26249be3 100644 --- a/gen/lib/src/error.rs +++ b/gen/lib/src/error.rs @@ -4,22 +4,30 @@ use std::error::Error as StdError; use std::fmt::{self, Debug, Display}; -pub struct Error(pub(crate) crate::gen::Error); +pub struct Error { + pub(crate) err: crate::gen::Error, +} + +impl From<crate::gen::Error> for Error { + fn from(err: crate::gen::Error) -> Self { + Error { err } + } +} impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&self.0, f) + Display::fmt(&self.err, f) } } impl Debug for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - Debug::fmt(&self.0, f) + Debug::fmt(&self.err, f) } } impl StdError for Error { fn source(&self) -> Option<&(dyn StdError + 'static)> { - self.0.source() + self.err.source() } } |