mirror of https://github.com/zkat/miette.git
feat(protocol): help is a single Display ref now.
This commit is contained in:
parent
7920a2315c
commit
80e7dabbe4
|
|
@ -30,7 +30,7 @@ pub trait Diagnostic: std::error::Error {
|
||||||
|
|
||||||
/// Additional help text related to this Diagnostic. Do you have any
|
/// Additional help text related to this Diagnostic. Do you have any
|
||||||
/// advice for the poor soul who's just run into this issue?
|
/// advice for the poor soul who's just run into this issue?
|
||||||
fn help(&self) -> Option<Box<dyn '_ + Iterator<Item = &'_ str>>> {
|
fn help(&self) -> Option<&(dyn Display)> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,10 +131,7 @@ impl DiagnosticReporter for MietteReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(help) = diagnostic.help() {
|
if let Some(help) = diagnostic.help() {
|
||||||
writeln!(f)?;
|
writeln!(f, "﹦{}", help)?;
|
||||||
for msg in help {
|
|
||||||
writeln!(f, "﹦{}", msg)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -162,9 +159,7 @@ impl DiagnosticReporter for JokeReporter {
|
||||||
diagnostic,
|
diagnostic,
|
||||||
diagnostic
|
diagnostic
|
||||||
.help()
|
.help()
|
||||||
.unwrap_or_else(|| Box::new(vec!["have you tried not failing?"].into_iter()))
|
.unwrap_or(&"have you tried not failing?")
|
||||||
.collect::<Vec<&str>>()
|
|
||||||
.join(" ")
|
|
||||||
)?;
|
)?;
|
||||||
writeln!(
|
writeln!(
|
||||||
f,
|
f,
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,8 @@ impl Diagnostic for MyBad {
|
||||||
&"oops::my::bad"
|
&"oops::my::bad"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
fn help(&self) -> Option<&(dyn std::fmt::Display)> {
|
||||||
|
Some(&"try doing it better next time?")
|
||||||
fn help(&self) -> Option<Box<dyn '_ + Iterator<Item = &'_ str>>> {
|
|
||||||
Some(Box::new(vec!["try doing it better next time?"].into_iter()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn snippets(&self) -> Option<&[DiagnosticSnippet]> {
|
fn snippets(&self) -> Option<&[DiagnosticSnippet]> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue