Skip to content

Commit

Permalink
chore: find ep number
Browse files Browse the repository at this point in the history
  • Loading branch information
gabelluardo committed Mar 17, 2024
1 parent 8442030 commit 31290db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ install:
cargo install --path . --target x86_64-unknown-linux-musl

test:
cargo nextest run --target x86_64-unknown-linux-musl
cargo nextest run

test-ignored:
cargo nextest run --run-ignored=ignored-only --target x86_64-unknown-linux-musl
cargo nextest run --run-ignored=ignored-only

test-all:
cargo nextest run --run-ignored=all

test-all-musl:
cargo nextest run --run-ignored=all --target x86_64-unknown-linux-musl

coverage:
Expand Down
15 changes: 8 additions & 7 deletions src/anime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ impl AnimeInfo {
pub fn new(name: &str, input: &str, id: Option<u32>, episodes: Option<Range<u32>>) -> Self {
// find episode number position in input
let (mut opt_start, mut opt_end) = (None, None);
for (i, c) in input.char_indices() {
if let Some(next) = input.chars().nth(i + 1) {
if c == '_' && next.is_ascii_digit() {
opt_start = Some(i);
} else if c.is_ascii_digit() && next == '_' {
opt_end = Some(i);
}
for i in 0..input.len() - 1 {
match (
input.chars().nth(i).unwrap(),
input.chars().nth(i + 1).unwrap(),
) {
('_', next) if next.is_ascii_digit() => opt_start = Some(i),
(curr, '_') if curr.is_ascii_digit() => opt_end = Some(i),
_ => continue,
}
}

Expand Down

0 comments on commit 31290db

Please sign in to comment.