RosettaCodeData/Task/Palindrome-detection/Rust/palindrome-detection-1.rust
2018-06-22 20:57:24 +00:00

20 lines
531 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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");
}