pub struct CodeLoc {
pub line: u32,
pub column: u32,
}Expand description
A line and column position in source code.
Uses 1-based indexing for both line and column to match Python’s conventions.
u32 matches ruff_text_size::TextSize, which underpins all source ranges
returned by the parser, so conversions between the two are zero-cost.
Fields§
§line: u32Line number (1-based).
column: u32Column number (1-based), counted in characters (not bytes).
Implementations§
Source§impl CodeLoc
impl CodeLoc
Sourcepub fn new(line: u32, column: u32) -> Self
pub fn new(line: u32, column: u32) -> Self
Creates a new CodeLoc from 0-based values.
Lines and columns numbers are 1-indexed for display, hence + 1.
Saturates at u32::MAX rather than panicking — overflow here is
already unreachable for any source ruff will accept (it caps source
size at 4 GiB), and saturation keeps the parser panic-free even if
that ever changes.
Trait Implementations§
impl Copy for CodeLoc
Source§impl<'de> Deserialize<'de> for CodeLoc
impl<'de> Deserialize<'de> for CodeLoc
Source§fn 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 Eq for CodeLoc
impl StructuralPartialEq for CodeLoc
Auto Trait Implementations§
impl Freeze for CodeLoc
impl RefUnwindSafe for CodeLoc
impl Send for CodeLoc
impl Sync for CodeLoc
impl Unpin for CodeLoc
impl UnsafeUnpin for CodeLoc
impl UnwindSafe for CodeLoc
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