Skip to content

Commit

Permalink
refactor: Restore str processing
Browse files Browse the repository at this point in the history
This is in prep for using unicase.
  • Loading branch information
epage committed Apr 17, 2019
1 parent 5992ba1 commit 719cc7d
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ pub fn process_file(path: &std::path::Path, dictionary: &Dictionary, report: rep
for (line_idx, line) in grep_searcher::LineIter::new(b'\n', &buffer).enumerate() {
let line_num = line_idx + 1;
for token in tokens::Symbol::parse(line) {
// Correct tokens as-is
if let Some(correction) = dictionary.correct_bytes(token.token) {
let word = String::from_utf8_lossy(token.token);
let col_num = token.offset;
let msg = report::Message {
path,
line,
line_num,
col_num,
word: word.as_ref(),
correction,
non_exhaustive: (),
};
report(msg);
if let Some(word) = std::str::from_utf8(token.token).ok() {
// Correct tokens as-is
if let Some(correction) = dictionary.correct_str(word) {
let col_num = token.offset;
let msg = report::Message {
path,
line,
line_num,
col_num,
word,
correction,
non_exhaustive: (),
};
report(msg);
}
}
}
}
Expand Down

0 comments on commit 719cc7d

Please sign in to comment.