devpage_core/problem.rs
1//! A problem: one broken thing a document holds, where it was found — the
2//! value link checking, the navbar, widgets and comments report, and the page
3//! lists above itself. A leaf: it depends on nothing else in devpage.
4
5/// One broken thing, where it was found.
6#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7pub struct Problem {
8 /// The file it is in, from the top of the served folder.
9 pub file: String,
10 pub line: Option<usize>,
11 pub message: String,
12 /// The link as written, so the page can mark it where it stands.
13 pub target: Option<String>,
14}
15
16impl std::fmt::Display for Problem {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 match self.line {
19 Some(line) => write!(f, "{}:{line}: {}", self.file, self.message),
20 None => write!(f, "{}: {}", self.file, self.message),
21 }
22 }
23}