mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Improve docs
This commit is contained in:
parent
ed498b6eff
commit
1cf74802ab
1 changed files with 5 additions and 4 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue