Skip to content

Commit

Permalink
Use core::error::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
djkoloski committed Sep 5, 2024
1 parent 3bbdb9d commit b16f4a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
22 changes: 9 additions & 13 deletions ptr_meta/src/impls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::any::Any;
use core::{any::Any, error::Error};

use crate::{DynMetadata, Pointee};

Expand All @@ -25,29 +25,25 @@ unsafe impl Pointee for dyn Any + Send + Sync {
type Metadata = DynMetadata<dyn Any + Send + Sync>;
}

#[cfg(feature = "std")]
// SAFETY: The metadata type of `dyn Error` is `DynMetadata<dyn Error>`.
unsafe impl Pointee for dyn std::error::Error {
type Metadata = DynMetadata<dyn std::error::Error>;
unsafe impl Pointee for dyn Error {
type Metadata = DynMetadata<dyn Error>;
}

#[cfg(feature = "std")]
// SAFETY: The metadata type of `dyn Error + Send` is
// `DynMetadata<dyn Error + Send>`.
unsafe impl Pointee for dyn std::error::Error + Send {
type Metadata = DynMetadata<dyn std::error::Error + Send>;
unsafe impl Pointee for dyn Error + Send {
type Metadata = DynMetadata<dyn Error + Send>;
}

#[cfg(feature = "std")]
// SAFETY: The metadata type of `dyn Error + Sync` is
// `DynMetadata<dyn Error + Sync>`.
unsafe impl Pointee for dyn std::error::Error + Sync {
type Metadata = DynMetadata<dyn std::error::Error + Sync>;
unsafe impl Pointee for dyn Error + Sync {
type Metadata = DynMetadata<dyn Error + Sync>;
}

#[cfg(feature = "std")]
// SAFETY: The metadata type of `dyn Error + Send + Sync` is
// `DynMetadata<dyn Error + Send + Sync>`.
unsafe impl Pointee for dyn std::error::Error + Send + Sync {
type Metadata = DynMetadata<dyn std::error::Error + Send + Sync>;
unsafe impl Pointee for dyn Error + Send + Sync {
type Metadata = DynMetadata<dyn Error + Send + Sync>;
}
2 changes: 1 addition & 1 deletion ptr_meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
//! - `slice`, `str`, and `CStr`
//! - `OsStr` (requires `std`)
//! - `dyn Any`, optionally with `+ Send` and/or `+ Sync`
//! - `dyn Error`, optionally with `+Send` and/or `+ Sync` (requires `std`)
//! - `dyn Error`, optionally with `+ Send` and/or `+ Sync`
//!
//! ## Structs with trailing DSTs
//!
Expand Down

0 comments on commit b16f4a7

Please sign in to comment.