km_crates_publish_test/
lib.rs

1use std::borrow::Cow;
2
3pub fn reverse<I: Into<String>>(input: I) -> String {
4    let s: String = input.into();
5
6    s.chars().rev().collect::<String>()
7}
8
9pub fn reverse2<I: Into<String>>(input: I) -> String {
10    let s: String = input.into();
11
12    s.chars().rev().collect::<String>()
13}
14
15#[must_use]
16pub fn to_bytes(input: Cow<'_, str>) -> Vec<u8> {
17    input.into_owned().into_bytes()
18}
19
20#[cfg(test)]
21mod tests {
22    use crate::{reverse, to_bytes};
23
24    #[test]
25    fn it_works() {
26        assert_eq!("fotsirk", reverse("kristof"));
27    }
28
29    #[test]
30    fn into_bytes() {
31        assert_eq!(
32            to_bytes("Hello, World".into()),
33            &[72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100]
34        );
35    }
36}