Skip to content

Commit

Permalink
Replaced ByteIndex::start() with ByteIndex(0) --- now that it's j…
Browse files Browse the repository at this point in the history
…ust an index, `0` is clearer than `start` (which made sense when there was other data beyond just the current byte)
  • Loading branch information
rben01 authored and sharkdp committed Sep 24, 2024
1 parent e467dcf commit e6bb921
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions numbat/src/ffi/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pub fn _get_chemical_element_data_raw(mut args: Args) -> Result<Value> {
.find(|e| e.name().to_lowercase() == pattern || e.symbol().to_lowercase() == pattern)
{
let unknown_span = Span {
start: ByteIndex::start(),
end: ByteIndex::start(),
start: ByteIndex(0),
end: ByteIndex(0),
code_source_id: 0,
};

Expand Down
8 changes: 2 additions & 6 deletions numbat/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ impl AddAssign<u32> for ByteIndex {
}

impl ByteIndex {
pub fn start() -> Self {
Self(0)
}

pub fn single_character_span(self, code_source_id: usize) -> Span {
Span {
start: self,
Expand Down Expand Up @@ -73,8 +69,8 @@ impl Span {
#[cfg(test)]
pub fn dummy() -> Span {
Self {
start: ByteIndex::start(),
end: ByteIndex::start(),
start: ByteIndex(0),
end: ByteIndex(0),
code_source_id: 0,
}
}
Expand Down
10 changes: 5 additions & 5 deletions numbat/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ fn char_at(s: &str, byte_index: usize) -> Option<char> {
impl Tokenizer {
fn new(code_source_id: usize) -> Self {
Tokenizer {
current: ByteIndex::start(),
last: ByteIndex::start(),
token_start: ByteIndex::start(),
current: ByteIndex(0),
last: ByteIndex(0),
token_start: ByteIndex(0),

code_source_id,
string_start: ByteIndex::start(),
interpolation_start: ByteIndex::start(),
string_start: ByteIndex(0),
interpolation_start: ByteIndex(0),
interpolation_state: InterpolationState::Outside,
}
}
Expand Down

0 comments on commit e6bb921

Please sign in to comment.