diff options
Diffstat (limited to 'src/rope.rs')
| -rw-r--r-- | src/rope.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rope.rs b/src/rope.rs index c5e9aa1..5f4fca8 100644 --- a/src/rope.rs +++ b/src/rope.rs @@ -278,4 +278,21 @@ impl Rope { } return self.len(); } + + pub fn char(&self, index: usize) -> usize { + if index == 0 { + return 0; + } + let mut count = 1; + for i in 1..self.len() { + if !self.is_char_boundary(i) { + continue; + } + if count == index { + return i; + } + count += 1; + } + return self.len(); + } } |
