Struct LineCol Copy item path Source pub struct LineCol {
pub line: u32 ,
pub col: u32 ,
}Expand description A resolved human coordinate: a 1-based line and a 1-based column.
The column counts Unicode scalar values (Rust chars), not bytes, not
UTF-16 code units, and not grapheme clusters. A column therefore never lands
inside a multi-byte UTF-8 sequence: the third char of a line is always
column 3, whether the preceding characters were one byte each or four.
Both fields are 1-based because that is what editors, compilers, and language
servers display — line 1, column 1 is the first character of the source.
LineCol is produced by LineIndex::line_col
and consumed by LineIndex::offset ; the two are
inverses for every valid byte position.
§ Examples
use span_lang::LineCol;
let lc = LineCol::new(2 , 5 );
assert_eq! (lc.line, 2 );
assert_eq! (lc.col, 5 );
assert_eq! (lc.to_string(), "2:5" );The 1-based column, counted in Unicode scalar values (chars).
Constructs a coordinate from a 1-based line and column.
This is a plain constructor; it does not validate that the coordinate
exists in any particular source. Resolving a coordinate back to a byte
offset is LineIndex::offset , which reports a
position outside the source as None.
§ Examples
use span_lang::LineCol;
const ORIGIN: LineCol = LineCol::new(1 , 1 );
assert_eq! ((ORIGIN.line, ORIGIN.col), (1 , 1 ));Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more Deserialize this value from the given Serde deserializer.
Read more Formats as line:col, the convention editors and compilers use.
Compares and returns the maximum of two values.
Read more Compares and returns the minimum of two values.
Read more Restrict a value to a certain interval.
Read more Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
This method returns an ordering between
self and
other values if one exists.
Read more Tests less than (for
self and
other) and is used by the
< operator.
Read more Tests less than or equal to (for
self and
other) and is used by the
<= operator.
Read more Tests greater than (for
self and
other) and is used by the
>
operator.
Read more Tests greater than or equal to (for
self and
other) and is used by
the
>= operator.
Read more Serialize this value into the given Serde serializer.
Read more Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more Converts the given value to a
String.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.