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
sourceimpl<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.
Trait Implementations
sourceimpl<'de, FileId> Deserialize<'de> for Label<FileId> where
FileId: Deserialize<'de>,
impl<'de, FileId> Deserialize<'de> for Label<FileId> where
FileId: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<FileId: Eq> Eq for Label<FileId>
impl<FileId> StructuralEq for Label<FileId>
impl<FileId> StructuralPartialEq for Label<FileId>
Auto Trait Implementations
impl<FileId> RefUnwindSafe for Label<FileId> where
FileId: RefUnwindSafe,
impl<FileId> Send for Label<FileId> where
FileId: Send,
impl<FileId> Sync for Label<FileId> where
FileId: Sync,
impl<FileId> Unpin for Label<FileId> where
FileId: Unpin,
impl<FileId> UnwindSafe for Label<FileId> where
FileId: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more