1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::{Iterable, Consumer};
impl<'a> Iterable for &'a str {
type C = String;
type CC<U> = Vec<U>;
type CR<'b> = String;
}
impl<'a> Consumer for &'a str {
type Item = char;
type IntoIter = std::str::Chars<'a>;
fn into_iter(self) -> Self::IntoIter {self.chars()}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_c() {
let v = "123你我";
let res = v.filter(|c| *c != '你');
assert_eq!(res, "123我".to_string());
}
#[test]
fn test_f() {
let v = "123你我";
let res = v.rev();
assert_eq!(res, "我你321".to_string());
}
#[test]
fn test_cc() {
let v = "123你我";
let res = v.map(|_| 1u8);
assert_eq!(res, vec![1, 1, 1, 1, 1]);
}
}