use std::ops::Range;
use yansi::Color;
use crate::FileId;
use super::Label;
pub struct LabelBuilder<Id: FileId> {
file: Id,
span: Range<usize>,
color: Color,
content: Option<String>,
}
impl<Id: FileId> Label<Id> {
pub const fn builder(file: Id, span: Range<usize>) -> LabelBuilder<Id> {
LabelBuilder {
file,
span,
color: Color::Primary,
content: None,
}
}
}
impl<Id: FileId> LabelBuilder<Id> {
pub const fn set_color(mut self, color: Color) -> Self {
self.color = color;
self
}
pub fn set_content(mut self, content: String) -> Self {
self.content = Some(content);
self
}
pub fn build(self) -> Label<Id> {
Label {
file: self.file,
span: self.span,
color: self.color,
content: self.content,
}
}
}