mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-09-28 05:21:34 +00:00
Add From<anyhow::Error> for Box<dyn std::error::Error>
This commit is contained in:
parent
3570a5ec2c
commit
b961f3a594
@ -572,6 +572,12 @@ impl From<Error> for Box<dyn StdError + Send + Sync + 'static> {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for Box<dyn StdError + 'static> {
|
||||
fn from(error: Error) -> Self {
|
||||
Box::<dyn StdError + Send + Sync>::from(error)
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterator of a chain of source errors.
|
||||
///
|
||||
/// This type is the iterator returned by [`Error::chain`].
|
||||
|
@ -1,7 +1,7 @@
|
||||
mod drop;
|
||||
|
||||
use self::drop::DetectDrop;
|
||||
use anyhow::Error;
|
||||
use anyhow::{Error, Result};
|
||||
use std::error::Error as StdError;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::Ordering::SeqCst;
|
||||
@ -16,3 +16,12 @@ fn test_convert() {
|
||||
drop(box_dyn);
|
||||
assert!(has_dropped.load(SeqCst));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_question_mark() -> Result<(), Box<dyn StdError>> {
|
||||
fn f() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
f()?;
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user