Unnamed repository; edit this file 'description' to name the repository.
Tweak comments, swap
Ariel Davis 2023-05-06
parent 594a41e · commit 0bb2153
-rw-r--r--lib/line-index/src/lib.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/line-index/src/lib.rs b/lib/line-index/src/lib.rs
index 463227900d..91b7faa78a 100644
--- a/lib/line-index/src/lib.rs
+++ b/lib/line-index/src/lib.rs
@@ -9,8 +9,8 @@ use nohash_hasher::IntMap;
pub use text_size::{TextRange, TextSize};
-/// Line/Column information in native, utf8 format.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+/// `(line, column)` information in the native, UTF-8 encoding.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct LineCol {
/// Zero-based.
pub line: u32,
@@ -19,7 +19,7 @@ pub struct LineCol {
}
/// A kind of wide character encoding.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WideEncoding {
/// UTF-16.
@@ -29,7 +29,7 @@ pub enum WideEncoding {
}
impl WideEncoding {
- /// Returns the number of units it takes to encode `text` in this encoding.
+ /// Returns the number of code units it takes to encode `text` in this encoding.
pub fn measure(&self, text: &str) -> usize {
match self {
WideEncoding::Utf16 => text.encode_utf16().count(),
@@ -38,10 +38,12 @@ impl WideEncoding {
}
}
-/// Line/Column information in legacy encodings.
+/// `(line, column)` information in wide encodings.
+///
+/// See [`WideEncoding`] for the kinds of wide encodings available.
//
// Deliberately not a generic type and different from `LineCol`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct WideLineCol {
/// Zero-based.
pub line: u32,
@@ -49,11 +51,11 @@ pub struct WideLineCol {
pub col: u32,
}
-#[derive(Clone, Debug, Hash, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct WideChar {
- /// Start offset of a character inside a line, zero-based
+ /// Start offset of a character inside a line, zero-based.
start: TextSize,
- /// End offset of a character inside a line, zero-based
+ /// End offset of a character inside a line, zero-based.
end: TextSize,
}