Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -1,25 +0,0 @@
|
|||
/// Tests if the given string slice is a palindrome (with the respect to
|
||||
/// codepoints, not graphemes).
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use playground::palindrome::is_palindrome;
|
||||
/// assert!(is_palindrome("abba"));
|
||||
/// assert!(!is_palindrome("baa"));
|
||||
/// ```
|
||||
pub fn is_palindrome(s: &str) -> bool {
|
||||
let half = s.len();
|
||||
s.chars().take(half).eq(s.chars().rev().take(half))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::is_palindrome;
|
||||
|
||||
#[test]
|
||||
fn test_is_palindrome() {
|
||||
assert!(is_palindrome("abba"));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue