[−][src]Struct tweep::Position
One-indexed, line and column numbers to be used within a Context
Examples
let c = Position::abs(1, 3); assert_eq!((c.line, c.column), (1, 3));
Fields
line: usize
The one-indexed line number
column: usize
The one-indexed column number
kind: PositionKind
Kind of position
Implementations
impl Position
[src]
pub fn abs(line: usize, column: usize) -> Self
[src]
Create a new absolute Position
Examples
let c = Position::abs(2, 3); assert_eq!((c.line, c.column), (2, 3));
pub fn rel(line: usize, column: usize) -> Self
[src]
Create a new relative Position
Examples
let c = Position::rel(2, 3); assert_eq!((c.line, c.column), (2, 3));
pub fn subposition(&self, line: usize, column: usize) -> Self
[src]
Creates another Position
using one-indexed line and column
numbers to offset from this position
Examples
let c = Position::abs(2, 3); // Since these are 1-indexed, this should be the same as c let s = c.subposition(1, 1); assert_eq!(c, s);
let c = Position::abs(2, 3); // When the line number is one, the sub position column will be offset // from the source position column let s = c.subposition(1, 3); assert_eq!(s, Position::abs(2, 5));
let c = Position::abs(2, 3); // When the line number is greater than one, the column number will be // offset from the start of that line let s = c.subposition(2, 1); assert_eq!(s, Position::abs(3, 1));
Trait Implementations
impl Clone for Position
[src]
impl Copy for Position
[src]
impl Debug for Position
[src]
impl Display for Position
[src]
impl Eq for Position
[src]
impl PartialEq<Position> for Position
[src]
impl StructuralEq for Position
[src]
impl StructuralPartialEq for Position
[src]
Auto Trait Implementations
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnwindSafe for Position
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,