fn split_on_same_scope(raw: Vec<Job>) -> Vec<Vec<Job>> {
    let mut to_return = Vec::new();
    let mut buffer = Vec::new();
    let mut nesting_level: usize = 0;
    for job in raw {
        match job.cmds[0].cmd.1.as_str() {
            "for" | "if" | "while" => {
                buffer.push(job);
                nesting_level += 1;
            }
            "done" | "end" => {
                buffer.push(job);
                nesting_level -= 1;
                if nesting_level == 0 {
                    to_return.push(buffer.clone());
                    buffer.clear();
                }
            }
            _ => {
                buffer.push(job);
            }
        }
    }
    if buffer.len() > 0 {
        to_return.push(buffer);
    }
    to_return
}
/// Splits a single scope into its individual constructs
Splits a single scope into its individual constructs
Splits a single scope into its individual constructs
fn split_on_same_scope(raw: Vec<Job>) -> Vec<Vec<Job>> {
    let mut to_return = Vec::new();
    let mut buffer = Vec::new();
    let mut nesting_level: usize = 0;
    for job in raw {
        match job.cmds[0].cmd.1.as_str() {
            "for" | "if" | "while" => {
                buffer.push(job);
                nesting_level += 1;
            }
            "done" | "end" => {
                buffer.push(job);
                nesting_level -= 1;
                if nesting_level == 0 {
                    to_return.push(buffer.clone());
                    buffer.clear();
                }
            }
            _ => {
                buffer.push(job);
            }
        }
    }
    if buffer.len() > 0 {
        to_return.push(buffer);
    }
    to_return
}
fn split_on_same_scope ( raw : Vec < Job > ) -> Vec < Vec < Job > > { let mut to_return = Vec :: new ( ) ; let mut buffer = Vec :: new ( ) ; let mut nesting_level : usize = 0 ; for job in raw { match job . cmds [ 0 ] . cmd . 1 . as_str ( ) { " " | " " | " " => { buffer . push ( job ) ; nesting_level += 1 ; } " " | " " => { buffer . push ( job ) ; nesting_level -= 1 ; if nesting_level == 0 { to_return . push ( buffer . clone ( ) ) ; buffer . clear ( ) ; } } _ => { buffer . push ( job ) ; } } } if buffer . len ( ) > 0 { to_return . push ( buffer ) ; } to_return }
Splits a single scope into its individual constructs
Splits a single scope into its individual constructs
raw
Vec<Job>