fn separate_files_in_group<F1, F2, T>(mut src: SourceGroup, categorize: F1, mut consume: F2)
where
    F1: Fn(&SourceFile) -> Option<T>,
    F2: FnMut(&SourceGroup, T, Vec<SourceFile>),
    T: Eq,
{
    let mut category = None;
    let mut files = vec![];
    for file in std::mem::replace(&mut src.files, vec![]) {
        let new_category = categorize(&file);
        if new_category.is_none() {
            continue;
        }
        if category.is_some() && category != new_category {
            if !files.is_empty() {
                consume(
                    &src,
                    std::mem::replace(&mut category, None).unwrap(),
                    std::mem::replace(&mut files, vec![]),
                );
            }
        }
        files.push(file);
        category = new_category;
    }
    if !files.is_empty() {
        consume(&src, category.unwrap(), files);
    }
}
/// Subdivide the source files in a group.
///
/// The function `cateogrize` is used to assign a category to each source file.
/// Files with the same category that appear after each other will be kept in
/// the same source group. Files with different cateogries are split into
/// separate groups.
Subdivide the source files in a group.
The function `cateogrize` is used to assign a category to each source file.
Files with the same category that appear after each other will be kept in
the same source group. Files with different cateogries are split into
separate groups.
Subdivide the source files in a group . The function ` cateogrize ` is used to assign a category to each source file . Files with the same category that appear after each other will be kept in the same source group . Files with different cateogries are split into separate groups .
fn separate_files_in_group<F1, F2, T>(mut src: SourceGroup, categorize: F1, mut consume: F2)
where
    F1: Fn(&SourceFile) -> Option<T>,
    F2: FnMut(&SourceGroup, T, Vec<SourceFile>),
    T: Eq,
{
    let mut category = None;
    let mut files = vec![];
    for file in std::mem::replace(&mut src.files, vec![]) {
        let new_category = categorize(&file);
        if new_category.is_none() {
            continue;
        }
        if category.is_some() && category != new_category {
            if !files.is_empty() {
                consume(
                    &src,
                    std::mem::replace(&mut category, None).unwrap(),
                    std::mem::replace(&mut files, vec![]),
                );
            }
        }
        files.push(file);
        category = new_category;
    }
    if !files.is_empty() {
        consume(&src, category.unwrap(), files);
    }
}
fn separate_files_in_group < F1 , F2 , T > ( mut src : SourceGroup , categorize : F1 , mut consume : F2 ) where F1 : Fn ( & SourceFile ) -> Option < T > , F2 : FnMut ( & SourceGroup , T , Vec < SourceFile > ) , T : Eq , { let mut category = None ; let mut files = vec ! [ ] ; for file in std :: mem :: replace ( & mut src . files , vec ! [ ] ) { let new_category = categorize ( & file ) ; if new_category . is_none ( ) { continue ; } if category . is_some ( ) && category != new_category { if ! files . is_empty ( ) { consume ( & src , std :: mem :: replace ( & mut category , None ) . unwrap ( ) , std :: mem :: replace ( & mut files , vec ! [ ] ) , ) ; } } files . push ( file ) ; category = new_category ; } if ! files . is_empty ( ) { consume ( & src , category . unwrap ( ) , files ) ; } }
Subdivide the source files in a group.
Subdivide the source files in a group .
src
SourceGroup
categorize
F1
consume
F2
src
SourceGroup
categorize
F1
consume
F2