Skip to content

Commit adf2bb5

Browse files
committed
feat: Allow bulk-adding of snippets, footers, annotations
This will make it easier for diagnostic systems to convert their messages to a `Message`
1 parent 42d8df6 commit adf2bb5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: src/snippet.rs

+15
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,20 @@ impl<'a> Message<'a> {
3434
self
3535
}
3636

37+
pub fn snippets(mut self, slice: impl IntoIterator<Item = Snippet<'a>>) -> Self {
38+
self.snippets.extend(slice);
39+
self
40+
}
41+
3742
pub fn footer(mut self, footer: Label<'a>) -> Self {
3843
self.footer.push(footer);
3944
self
4045
}
46+
47+
pub fn footers(mut self, footer: impl IntoIterator<Item = Label<'a>>) -> Self {
48+
self.footer.extend(footer);
49+
self
50+
}
4151
}
4252

4353
pub struct Label<'a> {
@@ -116,6 +126,11 @@ impl<'a> Snippet<'a> {
116126
self
117127
}
118128

129+
pub fn annotations(mut self, annotation: impl IntoIterator<Item = Annotation<'a>>) -> Self {
130+
self.annotations.extend(annotation);
131+
self
132+
}
133+
119134
pub fn fold(mut self, fold: bool) -> Self {
120135
self.fold = fold;
121136
self

0 commit comments

Comments
 (0)