mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-10-02 15:26:08 +00:00
Simplify downcast_ref and downcast_mut
This commit is contained in:
parent
83f63a6544
commit
8895b006a7
@ -290,7 +290,7 @@ impl Error {
|
|||||||
E: Display + Debug + Send + Sync + 'static,
|
E: Display + Debug + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
if self.is::<E>() {
|
if self.is::<E>() {
|
||||||
unsafe { Some(&*(self.inner.error() as *const dyn StdError as *const E)) }
|
Some(unsafe { &*(&self.inner.error as *const () as *const E) })
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -302,7 +302,7 @@ impl Error {
|
|||||||
E: Display + Debug + Send + Sync + 'static,
|
E: Display + Debug + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
if self.is::<E>() {
|
if self.is::<E>() {
|
||||||
unsafe { Some(&mut *(self.inner.error_mut() as *mut dyn StdError as *mut E)) }
|
Some(unsafe { &mut *(&mut self.inner.error as *mut () as *mut E) })
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user