Small changes
This commit is contained in:
parent
8517408765
commit
fb08be31d4
|
@ -15,6 +15,9 @@ termination = ["dep:ansee"]
|
||||||
ansee = { git = "https://git.pfaff.dev/michael/ansee", optional = true }
|
ansee = { git = "https://git.pfaff.dev/michael/ansee", optional = true }
|
||||||
typeid-cast = "0.1"
|
typeid-cast = "0.1"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
how = { path = ".", features = ["termination"] }
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "output"
|
name = "output"
|
||||||
required-features = [ "termination" ]
|
required-features = ["termination"]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::panic::Location;
|
use std::panic::Location;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::{How, IntoContext, Detail};
|
use crate::{Detail, How, IntoContext};
|
||||||
|
|
||||||
pub trait Explain: Sized {
|
pub trait Explain: Sized {
|
||||||
type Output;
|
type Output;
|
||||||
|
@ -40,6 +40,19 @@ impl Explain for How {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*impl<E> Explain for E
|
||||||
|
where
|
||||||
|
E: std::error::Error,
|
||||||
|
{
|
||||||
|
type Output = How;
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
#[track_caller]
|
||||||
|
fn context(self, context: impl IntoContext) -> Self::Output {
|
||||||
|
How::new(self.to_string()).context(context)
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
impl<T, E> Explain for Result<T, E>
|
impl<T, E> Explain for Result<T, E>
|
||||||
where
|
where
|
||||||
E: std::error::Error + 'static,
|
E: std::error::Error + 'static,
|
||||||
|
|
|
@ -9,7 +9,10 @@ use crate::report::report_write;
|
||||||
/// By default, does not implement [`Clone`] because [`std::backtrace::Backtrace`] does not
|
/// By default, does not implement [`Clone`] because [`std::backtrace::Backtrace`] does not
|
||||||
/// implement [`Clone`]. However, the `clone-with-caveats` feature may be used to enable a
|
/// implement [`Clone`]. However, the `clone-with-caveats` feature may be used to enable a
|
||||||
/// [`Clone`] impl that sets the cloned `backtrace` to [`std::backtrace::Backtrace::disabled`].
|
/// [`Clone`] impl that sets the cloned `backtrace` to [`std::backtrace::Backtrace::disabled`].
|
||||||
#[cfg_attr(any(feature = "arc-backtrace", feature = "clone-with-caveats"), derive(Clone))]
|
#[cfg_attr(
|
||||||
|
any(feature = "arc-backtrace", feature = "clone-with-caveats"),
|
||||||
|
derive(Clone)
|
||||||
|
)]
|
||||||
pub struct How(Box<HowInner>);
|
pub struct How(Box<HowInner>);
|
||||||
|
|
||||||
struct HowInner {
|
struct HowInner {
|
||||||
|
@ -145,6 +148,7 @@ impl std::fmt::Display for How {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
f.write_str("\n")?;
|
f.write_str("\n")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
report_write!(f, &opts.indent().next(), "{ctx}")?;
|
report_write!(f, &opts.indent().next(), "{ctx}")?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub(crate) use report_write;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write_indent(n: usize, f: &mut impl Write) -> std::fmt::Result {
|
fn write_indent(n: usize, f: &mut impl Write) -> std::fmt::Result {
|
||||||
for _ in 0..n {
|
for _ in 0..n {
|
||||||
f.write_str(" ")?;
|
f.write_str(" ")?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue