Skip to content

Commit

Permalink
improved readability of is_palindrome
Browse files Browse the repository at this point in the history
  • Loading branch information
craigmayhew committed Mar 20, 2024
1 parent 8c1c29a commit 9cc4392
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pages/cruncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,11 @@ mod numerics_to_text {

/// # Return a bool depending on the string being palindromic
pub fn is_palindrome(string: &str) -> bool {
let bytes = string.as_bytes();
let mut i = 0;
let mut j = string.len() - 1;
let mut j = bytes.len() - 1;
while i < j {
if &string.as_bytes()[i] != &string.as_bytes()[j] {
if bytes[i] != bytes[j] {
return false;
}
j -= 1;
Expand Down

0 comments on commit 9cc4392

Please sign in to comment.