Improve docs

This commit is contained in:
Ariel Davis 2023-05-06 15:14:02 -07:00
parent ed498b6eff
commit 1cf74802ab

View file

@ -143,14 +143,15 @@ impl LineIndex {
/// ///
/// # Panics /// # Panics
/// ///
/// If the offset is invalid. /// If the offset is invalid. See [`Self::try_line_col`].
pub fn line_col(&self, offset: TextSize) -> LineCol { pub fn line_col(&self, offset: TextSize) -> LineCol {
self.try_line_col(offset).expect("invalid offset") self.try_line_col(offset).expect("invalid offset")
} }
/// Transforms the `TextSize` into a `LineCol`, or returns `None` if the `offset` was invalid, /// Transforms the `TextSize` into a `LineCol`.
/// e.g. if it extends past the end of the text or points to the middle of a multi-byte ///
/// character. /// Returns `None` if the `offset` was invalid, e.g. if it extends past the end of the text or
/// points to the middle of a multi-byte character.
pub fn try_line_col(&self, offset: TextSize) -> Option<LineCol> { pub fn try_line_col(&self, offset: TextSize) -> Option<LineCol> {
if offset > self.size { if offset > self.size {
return None; return None;