pub struct Span { /* private fields */ }
Expand description
A span that records source code locations.
Used to print error messages.
Implementations§
Source§impl Span
impl Span
Sourcepub fn log_raw_error(&self, args: Arguments<'_>) -> Error
Available on crate feature logger
only.
pub fn log_raw_error(&self, args: Arguments<'_>) -> Error
logger
only.Logs normal error with no span provided.
Sourcepub fn log_raw_fatal_error(&self, args: Arguments<'_>) -> Error
Available on crate feature logger
only.
pub fn log_raw_fatal_error(&self, args: Arguments<'_>) -> Error
logger
only.Logs fatal error with no span provided.
Sourcepub fn log_raw_warning(&self, args: Arguments<'_>)
Available on crate feature logger
only.
pub fn log_raw_warning(&self, args: Arguments<'_>)
logger
only.Logs warning with no span provided.
Sourcepub fn log_summary(&self)
Available on crate feature logger
only.
pub fn log_summary(&self)
logger
only.Logs summary information (total error/warning number).
Sourcepub fn warning_num(&self) -> usize
pub fn warning_num(&self) -> usize
Gets the number of warnings.
Sourcepub fn log_error(&self, args: Arguments<'_>) -> Error
Available on crate feature logger
only.
pub fn log_error(&self, args: Arguments<'_>) -> Error
logger
only.Logs normal error message.
Sourcepub fn log_fatal_error(&self, args: Arguments<'_>) -> Error
Available on crate feature logger
only.
pub fn log_fatal_error(&self, args: Arguments<'_>) -> Error
logger
only.Logs fatal error message.
Sourcepub fn log_warning(&self, args: Arguments<'_>)
Available on crate feature logger
only.
pub fn log_warning(&self, args: Arguments<'_>)
logger
only.Logs warning message.
Sourcepub fn update<C>(&mut self, c: &C)where
C: LocationUpdate,
pub fn update<C>(&mut self, c: &C)where
C: LocationUpdate,
Updates the line number ans column number of the start location based on the given character, then set the end location to the start position.
§Examples
use laps::span::{FileType, Span};
let mut span = Span::new(FileType::Buffer);
assert_eq!(format!("{span}"), "1:0-1:0");
span.update(&' ');
assert_eq!(format!("{span}"), "1:1-1:1");
span.update(&'\n');
assert_eq!(format!("{span}"), "2:0-2:0");
Sourcepub fn into_updated<C>(self, c: &C) -> Selfwhere
C: LocationUpdate,
pub fn into_updated<C>(self, c: &C) -> Selfwhere
C: LocationUpdate,
Converts the current span into a new one where the location has been updated.
Sourcepub fn update_loc(&mut self, loc: Location)
pub fn update_loc(&mut self, loc: Location)
Updates both the start and the end location to the given location.
Sourcepub fn update_end<S>(&mut self, span: S)where
S: AsRef<Self>,
pub fn update_end<S>(&mut self, span: S)where
S: AsRef<Self>,
Updates the end location according to the given span.
§Examples
use laps::span::{FileType, Span};
let mut span = Span::new(FileType::Buffer);
span.update_end(&span.clone().into_updated(&'\n'));
assert_eq!(format!("{span}"), "1:0-2:0");
Sourcepub fn into_end_updated<S>(self, span: S) -> Selfwhere
S: AsRef<Self>,
pub fn into_end_updated<S>(self, span: S) -> Selfwhere
S: AsRef<Self>,
Converts the current span into a new one where the end location has been updated according to the given span.
Sourcepub fn is_in_same_line_as<S>(&self, span: S) -> boolwhere
S: AsRef<Self>,
pub fn is_in_same_line_as<S>(&self, span: S) -> boolwhere
S: AsRef<Self>,
Checks if the current span is in the same line as the given span.
§Examples
use laps::span::{FileType, Span};
let span = Span::new(FileType::Buffer);
let span2 = span.clone().into_updated(&' ');
assert!(span.is_in_same_line_as(&span2));
let span3 = span.clone().into_updated(&'\n');
assert!(!span.is_in_same_line_as(&span3));