标签:let lang for amp char collect inter ring map
extern crate itertools;
use itertools::Itertools;
fn main() {
let text = "床前明月光疑是地上霜举头望明月低头思故乡";
let offset = 5;
let v = text.chars().enumerate().sorted_by_key(|x| x.0 % offset).collect_vec();
for (_, group) in &v.into_iter().group_by(|x| x.0 % offset) {
let s: String = group.map(|x| x.1).collect_vec().into_iter().rev().intersperse(‘|‘).collect();
println!("{}", s);
}
}
/*
低|举|疑|床
头|头|是|前
思|望|地|明
故|明|上|月
乡|月|霜|光
*/
标签:let lang for amp char collect inter ring map
原文地址:https://www.cnblogs.com/zwvista/p/12703623.html