20 lines
531 B
Text
20 lines
531 B
Text
fn is_palindrome(string: &str) -> bool {
|
||
let half_len = string.len()/2;
|
||
string.chars().take(half_len).eq(string.chars().rev().take(half_len))
|
||
}
|
||
|
||
macro_rules! test {
|
||
( $( $x:tt ),* ) => { $( println!("'{}': {}", $x, is_palindrome($x)); )* };
|
||
}
|
||
|
||
fn main() {
|
||
test!("",
|
||
"a",
|
||
"ada",
|
||
"adad",
|
||
"ingirumimusnocteetconsumimurigni",
|
||
"人人為我,我為人人",
|
||
"Я иду с мечем, судия",
|
||
"아들딸들아",
|
||
"The quick brown fox");
|
||
}
|