mintyml 0.1.19

A minialist alternative syntax to HTML
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub fn trim_multiline<'src>(src: &'src str) -> impl Iterator<Item = &'src str> {
    src.split_once('\n')
        .and_then(|(_, src)| src.rsplit_once('\n'))
        .and_then(|(src, last)| {
            let prefix = last
                .find(|c: char| !c.is_whitespace())
                .and_then(|len| last.get(..len))
                .unwrap_or(last);

            src.strip_suffix('\r')
                .unwrap_or(src)
                .split_inclusive('\n')
                .map(move |l| l.strip_prefix(prefix).unwrap_or(l))
                .into()
        })
        .into_iter()
        .flatten()
}