2个稳定版本
使用旧的Rust 2015
1.1.0 | 2016年11月8日 |
---|---|
1.0.0 | 2016年11月1日 |
613 在 编程语言 中
11KB
242 行
splits_iter
Rust编程语言的库。提供所有2分的迭代器。2分是一种操作,将一个序列s
分割成两个,当它们连接时创建原始序列(split_at(s,_)=(s1,s2)
,使得concat(s1,s2)=s
)。
示例
let mut i = Splits::from_str("0123456789");
/*01*/assert_eq!(i.next(),Some(("0","123456789")));
/*02*/assert_eq!(i.next(),Some(("01","23456789")));
/*03*/assert_eq!(i.next(),Some(("012","3456789")));
/*04*/assert_eq!(i.next(),Some(("0123","456789")));
/*05*/assert_eq!(i.next(),Some(("01234","56789")));
/*06*/assert_eq!(i.next(),Some(("012345","6789")));
/*07*/assert_eq!(i.next(),Some(("0123456","789")));
/*08*/assert_eq!(i.next(),Some(("01234567","89")));
/*09*/assert_eq!(i.next(),Some(("012345678","9")));
/*10*/assert_eq!(i.next(),Some(("0123456789","")));
/*11*/assert_eq!(i.next(),None);
let mut i = FocusedSplits::from_str("0123456789");
/*01*/assert_eq!(i.next(),Some(("",'0',"123456789")));
/*02*/assert_eq!(i.next(),Some(("0",'1',"23456789")));
/*03*/assert_eq!(i.next(),Some(("01",'2',"3456789")));
/*04*/assert_eq!(i.next(),Some(("012",'3',"456789")));
/*05*/assert_eq!(i.next(),Some(("0123",'4',"56789")));
/*06*/assert_eq!(i.next(),Some(("01234",'5',"6789")));
/*07*/assert_eq!(i.next(),Some(("012345",'6',"789")));
/*08*/assert_eq!(i.next(),Some(("0123456",'7',"89")));
/*09*/assert_eq!(i.next(),Some(("01234567",'8',"9")));
/*10*/assert_eq!(i.next(),Some(("012345678",'9',"")));`