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
|
||||
/// 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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,10 +131,7 @@ impl DiagnosticReporter for MietteReporter {
|
|||
}
|
||||
|
||||
if let Some(help) = diagnostic.help() {
|
||||
writeln!(f)?;
|
||||
for msg in help {
|
||||
writeln!(f, "﹦{}", msg)?;
|
||||
}
|
||||
writeln!(f, "﹦{}", help)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
@ -162,9 +159,7 @@ impl DiagnosticReporter for JokeReporter {
|
|||
diagnostic,
|
||||
diagnostic
|
||||
.help()
|
||||
.unwrap_or_else(|| Box::new(vec!["have you tried not failing?"].into_iter()))
|
||||
.collect::<Vec<&str>>()
|
||||
.join(" ")
|
||||
.unwrap_or(&"have you tried not failing?")
|
||||
)?;
|
||||
writeln!(
|
||||
f,
|
||||
|
|
|
|||
|
|
@ -23,10 +23,8 @@ impl Diagnostic for MyBad {
|
|||
&"oops::my::bad"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn help(&self) -> Option<Box<dyn '_ + Iterator<Item = &'_ str>>> {
|
||||
Some(Box::new(vec!["try doing it better next time?"].into_iter()))
|
||||
fn help(&self) -> Option<&(dyn std::fmt::Display)> {
|
||||
Some(&"try doing it better next time?")
|
||||
}
|
||||
|
||||
fn snippets(&self) -> Option<&[DiagnosticSnippet]> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue