skeleton
This commit is contained in:
parent
d8ac4e157d
commit
bcd11513ef
12 changed files with 1042 additions and 5 deletions
32
src/line.rs
Normal file
32
src/line.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
use std::num::NonZeroU64;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use crate::prelude::*;
|
||||
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Line(pub u64);
|
||||
|
||||
/// Constructors.
|
||||
impl Line {
|
||||
pub fn from_index(index: u64) -> Self {
|
||||
Self(index)
|
||||
}
|
||||
|
||||
pub fn from_linenr(linenr: NonZeroU64) -> Self {
|
||||
Self(linenr.get() - 1)
|
||||
}
|
||||
}
|
||||
|
||||
/// Getters.
|
||||
impl Line {
|
||||
/// 0-indexed
|
||||
pub fn index(self) -> u64 {
|
||||
self.0
|
||||
}
|
||||
|
||||
/// 1-indexed
|
||||
pub fn linenr(self) -> u64 {
|
||||
self.0 + 1
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue