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);