Skip to content

Commit

Permalink
Sealed trait does not need its own module
Browse files Browse the repository at this point in the history
The aserror module is already private to thiserror, with AsDynError
being re-exported in thiserror::private, so as long as Sealed is not
also re-exported there, it remains inaccessible outside the crate.
  • Loading branch information
dtolnay committed Sep 13, 2022
1 parent 12acbc5 commit 37442be
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/aserror.rs
@@ -1,4 +1,3 @@
use self::private::Sealed;
use std::error::Error;
use std::panic::UnwindSafe;

Expand Down Expand Up @@ -41,13 +40,9 @@ impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a {
}
}

mod private {
use super::*;

pub trait Sealed {}
impl<'a, T: Error + 'a> Sealed for T {}
impl<'a> Sealed for dyn Error + 'a {}
impl<'a> Sealed for dyn Error + Send + 'a {}
impl<'a> Sealed for dyn Error + Send + Sync + 'a {}
impl<'a> Sealed for dyn Error + Send + Sync + UnwindSafe + 'a {}
}
pub trait Sealed {}
impl<'a, T: Error + 'a> Sealed for T {}
impl<'a> Sealed for dyn Error + 'a {}
impl<'a> Sealed for dyn Error + Send + 'a {}
impl<'a> Sealed for dyn Error + Send + Sync + 'a {}
impl<'a> Sealed for dyn Error + Send + Sync + UnwindSafe + 'a {}

0 comments on commit 37442be

Please sign in to comment.