summaryrefslogtreecommitdiff
path: root/src/syntax/tokens.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-12-12 22:19:38 +0100
committerLaurenz <laurmaedje@gmail.com>2019-12-12 22:19:38 +0100
commitff107cf3e75acf041f8b7631337d299cdeaa1685 (patch)
tree40799f0337a5c2bc13166ff32a1f0b4f5c23bfe8 /src/syntax/tokens.rs
parent3c0496bb6104f0e2a60520e42137ecc29f26e9fa (diff)
Tidying up 🧹
Diffstat (limited to 'src/syntax/tokens.rs')
-rw-r--r--src/syntax/tokens.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/syntax/tokens.rs b/src/syntax/tokens.rs
index 95b2ea3e..cca8bee3 100644
--- a/src/syntax/tokens.rs
+++ b/src/syntax/tokens.rs
@@ -1,5 +1,6 @@
use std::str::CharIndices;
use smallvec::SmallVec;
+
use super::*;
/// Builds an iterator over the tokens of the source code.
@@ -266,7 +267,7 @@ fn is_newline_char(character: char) -> bool {
/// A (index, char) iterator with double lookahead.
#[derive(Debug, Clone)]
-pub struct PeekableChars<'s> {
+struct PeekableChars<'s> {
string: &'s str,
chars: CharIndices<'s>,
peeked: SmallVec<[Option<(usize, char)>; 2]>,
@@ -276,7 +277,7 @@ pub struct PeekableChars<'s> {
impl<'s> PeekableChars<'s> {
/// Create a new iterator from a string.
- pub fn new(string: &'s str) -> PeekableChars<'s> {
+ fn new(string: &'s str) -> PeekableChars<'s> {
PeekableChars {
string,
chars: string.char_indices(),
@@ -287,17 +288,17 @@ impl<'s> PeekableChars<'s> {
}
/// Peek at the next element.
- pub fn peek(&mut self) -> Option<(usize, char)> {
+ fn peek(&mut self) -> Option<(usize, char)> {
self.peekn(0)
}
/// Peek at the char of the next element.
- pub fn peekc(&mut self) -> Option<char> {
+ fn peekc(&mut self) -> Option<char> {
self.peekn(0).map(|p| p.1)
}
/// Peek at the element after the next element.
- pub fn peekn(&mut self, n: usize) -> Option<(usize, char)> {
+ fn peekn(&mut self, n: usize) -> Option<(usize, char)> {
while self.peeked.len() <= n {
let next = self.next_inner();
self.peeked.push(next);
@@ -307,15 +308,15 @@ impl<'s> PeekableChars<'s> {
}
/// Return the next value of the inner iterator mapped with the offset.
- pub fn next_inner(&mut self) -> Option<(usize, char)> {
+ fn next_inner(&mut self) -> Option<(usize, char)> {
self.chars.next().map(|(i, c)| (self.base + i, c))
}
- pub fn string_index(&mut self) -> usize {
+ fn string_index(&mut self) -> usize {
self.index
}
- pub fn set_string_index(&mut self, index: usize) {
+ fn set_string_index(&mut self, index: usize) {
self.chars = self.string[index..].char_indices();
self.base = index;
self.index = 0;