fix(chain): correct `Chain` structure exported (#102)

This fixes all current complier and clippy warnings.
This commit is contained in:
Paul Colomiets 2022-01-08 03:34:39 +02:00 committed by GitHub
parent 53b246829a
commit 52e5ec8064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 26 deletions

View File

@ -8,6 +8,25 @@ use std::vec;
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)]
#[allow(missing_debug_implementations)]
pub struct Chain<'a> {
@ -25,7 +44,7 @@ pub(crate) enum ChainState<'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 {
state: ChainState::Linked { next: Some(head) },
}

View File

@ -191,31 +191,6 @@ pub trait ReportHandler: core::any::Any + Send + Sync {
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>`
///
/// This is a reasonable return type to use throughout your application but also for `fn main`; if

View File

@ -19,6 +19,7 @@ macro_rules! context_type {
#[derive(Debug)]
struct $name {
message: &'static str,
#[allow(dead_code)]
drop: DetectDrop,
}