restore old files now!

This commit is contained in:
Qyriad 2026-02-16 18:02:39 +01:00
parent 76b5ac628d
commit dfdf027bc6
11 changed files with 1676 additions and 16 deletions

43
src/line.rs Normal file
View file

@ -0,0 +1,43 @@
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 const fn from_index(index: u64) -> Self {
Self(index)
}
pub const fn from_linenr(linenr: NonZeroU64) -> Self {
Self(linenr.get() - 1)
}
pub const fn next(self) -> Self {
Self::from_index(self.index() + 1)
}
/// Panics if self is line index 0.
pub const fn prev(self) -> Self {
Self::from_index(self.index() - 1)
}
}
/// Getters.
impl Line {
/// 0-indexed
pub const fn index(self) -> u64 {
self.0
}
/// 1-indexed
pub const fn linenr(self) -> u64 {
self.0 + 1
}
}
pub struct Lines(Vec<Line>);