Skip to content

Commit

Permalink
refactor(oxc): ban index methods on std::str::Chars (#6075)
Browse files Browse the repository at this point in the history
closes #6071
  • Loading branch information
shulaoda authored Oct 10, 2024
1 parent c5deb32 commit f70e93b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,16 @@ jobs:
with:
cache-key: warm
components: clippy
tools: ast-grep
- run: cargo lint -- -D warnings
- name: Check Char and Byte Offset
run: |
output=$(sg -p '$A.chars().enumerate()' -r '$A.char_indices()' -l rs)
echo "Output: $output"
if [ -n "$output" ]; then
echo "Error: Unexpected output detected"
exit 1
fi
doc:
name: Doc
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/nextjs/no_typos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ fn min_distance(a: &str, b: &str) -> usize {

let mut previous_row: Vec<usize> = (0..=n).collect();

for (i, s1) in a.chars().enumerate() {
for (i, s1) in a.char_indices() {
let mut current_row = vec![i + 1];
for (j, s2) in b.chars().enumerate() {
for (j, s2) in b.char_indices() {
let insertions = previous_row[j + 1] + 1;
let deletions = current_row[j] + 1;
let substitutions = previous_row[j] + usize::from(s1 != s2);
Expand Down

0 comments on commit f70e93b

Please sign in to comment.