pub struct Location { /* private fields */ }Expand description
A location in a file.
Implementations§
source§impl Location
impl Location
sourcepub fn new(file: Arc<File>, offset: usize) -> Self
pub fn new(file: Arc<File>, offset: usize) -> Self
Creates a new Location with the given file and offset.
§Panics
Panics if the given offset is out of bounds for the file’s source.
Examples found in repository?
examples/basic.rs (line 13)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let file = File::new("test.txt", "import stds;");
let styles = Styles::styled();
print!(
"{}",
Renderer::new(
&styles,
&[
error!("Could not find package `{}`", "stds")
.location(Location::new(file.clone(), 7)),
note!("Perhaps you meant `std`?")
]
)
);
}sourcepub fn try_new(file: Arc<File>, offset: usize) -> Option<Self>
pub fn try_new(file: Arc<File>, offset: usize) -> Option<Self>
Attempts to create a Location with the given file and offset, returning None if the
offset is out of bounds.
sourcepub fn line_column(&self) -> (usize, usize)
pub fn line_column(&self) -> (usize, usize)
Returns the line and column number of this source location within its file.
Trait Implementations§
source§impl PartialEq for Location
impl PartialEq for Location
impl Eq for Location
impl StructuralPartialEq for Location
Auto Trait Implementations§
impl Freeze for Location
impl RefUnwindSafe for Location
impl Send for Location
impl Sync for Location
impl Unpin for Location
impl UnwindSafe for Location
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)