mirror of https://github.com/zkat/miette.git
fix(chain): correct `Chain` structure exported (#102)
This fixes all current complier and clippy warnings.
This commit is contained in:
parent
53b246829a
commit
52e5ec8064
21
src/chain.rs
21
src/chain.rs
|
|
@ -8,6 +8,25 @@ use std::vec;
|
||||||
|
|
||||||
use ChainState::*;
|
use ChainState::*;
|
||||||
|
|
||||||
|
/// Iterator of a chain of source errors.
|
||||||
|
///
|
||||||
|
/// This type is the iterator returned by [`Report::chain`].
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use miette::Report;
|
||||||
|
/// use std::io;
|
||||||
|
///
|
||||||
|
/// pub fn underlying_io_error_kind(error: &Report) -> Option<io::ErrorKind> {
|
||||||
|
/// for cause in error.chain() {
|
||||||
|
/// if let Some(io_error) = cause.downcast_ref::<io::Error>() {
|
||||||
|
/// return Some(io_error.kind());
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// None
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Chain<'a> {
|
pub struct Chain<'a> {
|
||||||
|
|
@ -25,7 +44,7 @@ pub(crate) enum ChainState<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Chain<'a> {
|
impl<'a> Chain<'a> {
|
||||||
pub fn new(head: &'a (dyn StdError + 'static)) -> Self {
|
pub(crate) fn new(head: &'a (dyn StdError + 'static)) -> Self {
|
||||||
Chain {
|
Chain {
|
||||||
state: ChainState::Linked { next: Some(head) },
|
state: ChainState::Linked { next: Some(head) },
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,31 +191,6 @@ pub trait ReportHandler: core::any::Any + Send + Sync {
|
||||||
fn track_caller(&mut self, location: &'static std::panic::Location<'static>) {}
|
fn track_caller(&mut self, location: &'static std::panic::Location<'static>) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterator of a chain of source errors.
|
|
||||||
///
|
|
||||||
/// This type is the iterator returned by [`Report::chain`].
|
|
||||||
///
|
|
||||||
/// # Example
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// use miette::Report;
|
|
||||||
/// use std::io;
|
|
||||||
///
|
|
||||||
/// pub fn underlying_io_error_kind(error: &Report) -> Option<io::ErrorKind> {
|
|
||||||
/// for cause in error.chain() {
|
|
||||||
/// if let Some(io_error) = cause.downcast_ref::<io::Error>() {
|
|
||||||
/// return Some(io_error.kind());
|
|
||||||
/// }
|
|
||||||
/// }
|
|
||||||
/// None
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
#[derive(Clone)]
|
|
||||||
#[allow(missing_debug_implementations)]
|
|
||||||
pub struct Chain<'a> {
|
|
||||||
state: crate::chain::ChainState<'a>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// type alias for `Result<T, Report>`
|
/// type alias for `Result<T, Report>`
|
||||||
///
|
///
|
||||||
/// This is a reasonable return type to use throughout your application but also for `fn main`; if
|
/// This is a reasonable return type to use throughout your application but also for `fn main`; if
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ macro_rules! context_type {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct $name {
|
struct $name {
|
||||||
message: &'static str,
|
message: &'static str,
|
||||||
|
#[allow(dead_code)]
|
||||||
drop: DetectDrop,
|
drop: DetectDrop,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue