逆序倒转
pub fn reverse(text: &str) -> String {
text.chars().rev().collect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_simple() {
assert_eq!(reverse("racecar"), "racecar");
}
#[test]
fn test_sentence() {
assert_eq!(reverse("step on no pets"), "step on no pets");
}
}
当前内容版权归 rustlang-cn 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 rustlang-cn .