rajac_diagnostics/
diagnostics.rs1use crate::diagnostic::Diagnostic;
2
3#[derive(Debug, Default)]
4pub struct Diagnostics {
5 diagnostics: Vec<Diagnostic>,
6}
7
8impl Diagnostics {
9 pub fn new() -> Self {
10 Self::default()
11 }
12
13 pub fn add(&mut self, diagnostic: Diagnostic) {
14 self.diagnostics.push(diagnostic);
15 }
16
17 pub fn extend(&mut self, diagnostics: impl IntoIterator<Item = Diagnostic>) {
18 self.diagnostics.extend(diagnostics);
19 }
20
21 pub fn iter(&self) -> impl Iterator<Item = &Diagnostic> {
22 self.diagnostics.iter()
23 }
24
25 pub fn len(&self) -> usize {
26 self.diagnostics.len()
27 }
28
29 pub fn is_empty(&self) -> bool {
30 self.diagnostics.is_empty()
31 }
32}
33
34impl IntoIterator for Diagnostics {
35 type Item = Diagnostic;
36 type IntoIter = std::vec::IntoIter<Diagnostic>;
37
38 fn into_iter(self) -> Self::IntoIter {
39 self.diagnostics.into_iter()
40 }
41}
42
43impl<'a> IntoIterator for &'a Diagnostics {
44 type Item = &'a Diagnostic;
45 type IntoIter = std::slice::Iter<'a, Diagnostic>;
46
47 fn into_iter(self) -> Self::IntoIter {
48 self.diagnostics.iter()
49 }
50}