Skip to content

Commit 0258341

Browse files
committed
Add TODOs
1 parent bad3837 commit 0258341

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ use std::{fmt, iter, ops};
66
/// An offset into text.
77
/// Offset is represented as `u32` storing number of utf8-bytes,
88
/// but most of the clients should treat it like opaque measure.
9+
// BREAK: TextSize(u32)
910
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
1011
pub struct TextUnit(u32);
1112

1213
impl TextUnit {
13-
//TODO: rename to `from_char`: this is not ocaml!
14+
// BREAK: consider renaming?
1415
/// `TextUnit` equal to the length of this char.
1516
#[inline(always)]
1617
pub fn of_char(c: char) -> TextUnit {
1718
TextUnit(c.len_utf8() as u32)
1819
}
1920

21+
// BREAK: consider renaming?
2022
/// `TextUnit` equal to the length of this string.
2123
///
2224
/// # Panics
@@ -233,6 +235,8 @@ impl fmt::Display for TextRange {
233235
}
234236

235237
impl TextRange {
238+
// BREAK: TextRange::new(from..to)?
239+
// BREAK: TextRange(from, to)?
236240
/// The left-inclusive range (`[from..to)`) between to points in the text
237241
#[inline(always)]
238242
pub fn from_to(from: TextUnit, to: TextUnit) -> TextRange {
@@ -249,36 +253,41 @@ impl TextRange {
249253
TextRange::from_to(offset, offset + len)
250254
}
251255

252-
// TODO: pass by value
256+
// BREAK: pass by value
253257
/// The inclusive start of this range
254258
#[inline(always)]
255259
pub fn start(&self) -> TextUnit {
256260
self.start
257261
}
258262

263+
// BREAK: pass by value
259264
/// The exclusive end of this range
260265
#[inline(always)]
261266
pub fn end(&self) -> TextUnit {
262267
self.end
263268
}
264269

270+
// BREAK: pass by value
265271
/// The length of this range
266272
#[inline(always)]
267273
pub fn len(&self) -> TextUnit {
268274
self.end - self.start
269275
}
270276

277+
// BREAK: pass by value
271278
/// Is this range empty of any content?
272279
#[inline(always)]
273280
pub fn is_empty(&self) -> bool {
274281
self.start() == self.end()
275282
}
276283

284+
// BREAK: pass by value
277285
#[inline(always)]
278286
pub fn is_subrange(&self, other: &TextRange) -> bool {
279287
other.start() <= self.start() && self.end() <= other.end()
280288
}
281289

290+
// BREAK: pass by value
282291
#[inline(always)]
283292
pub fn intersection(&self, other: &TextRange) -> Option<TextRange> {
284293
let start = self.start.max(other.start());
@@ -290,11 +299,13 @@ impl TextRange {
290299
}
291300
}
292301

302+
// BREAK: pass by value
293303
#[inline(always)]
294304
pub fn contains(&self, offset: TextUnit) -> bool {
295305
self.start() <= offset && offset < self.end()
296306
}
297307

308+
// BREAK: pass by value
298309
#[inline(always)]
299310
pub fn contains_inclusive(&self, offset: TextUnit) -> bool {
300311
self.start() <= offset && offset <= self.end()

0 commit comments

Comments
 (0)