Struct codespan_reporting::diagnostic::Label
source · pub struct Label<FileId> {
pub style: LabelStyle,
pub file_id: FileId,
pub range: Range<usize>,
pub message: String,
}
Expand description
A label describing an underlined region of code associated with a diagnostic.
Fields§
§style: LabelStyle
The style of the label.
file_id: FileId
The file that we are labelling.
range: Range<usize>
The range in bytes we are going to include in the final snippet.
message: String
An optional message to provide some additional information for the underlined code. These should not include line breaks.
Implementations§
source§impl<FileId> Label<FileId>
impl<FileId> Label<FileId>
sourcepub fn new(
style: LabelStyle,
file_id: FileId,
range: impl Into<Range<usize>>
) -> Label<FileId>
pub fn new(
style: LabelStyle,
file_id: FileId,
range: impl Into<Range<usize>>
) -> Label<FileId>
Create a new label.
sourcepub fn primary(file_id: FileId, range: impl Into<Range<usize>>) -> Label<FileId>
pub fn primary(file_id: FileId, range: impl Into<Range<usize>>) -> Label<FileId>
Create a new label with a style of LabelStyle::Primary
.
sourcepub fn secondary(
file_id: FileId,
range: impl Into<Range<usize>>
) -> Label<FileId>
pub fn secondary(
file_id: FileId,
range: impl Into<Range<usize>>
) -> Label<FileId>
Create a new label with a style of LabelStyle::Secondary
.
sourcepub fn with_message(self, message: impl Into<String>) -> Label<FileId>
pub fn with_message(self, message: impl Into<String>) -> Label<FileId>
Add a message to the diagnostic.