fn sanitize_overlaping(args: &[(usize, Box<dyn IArgLeaf>)], size: usize) -> bool {
    args
        .iter()
        .enumerate()
        .any(|(ind, arg_couple)| {
            let range: Range<usize> = arg_couple.0..arg_couple.0+arg_couple.1.size();
            if range.end > size {
                panic!("ArgComposite oversized with leafs {} vs {}", size, range.end);
            }
            args[ind+1..]
                .iter()
                .any(|&(start, ref arg)| {
                    if range.start >= start + arg.size() || range.end <= start {
                        false
                    } else {
                        println!("overlap in [ {} vs {} ] => {} {} -> {} {}",
                                arg_couple.1.name(), arg.name(),
                                range.start, range.end,
                                start, start + arg.size());
                        true
                    }
                })
        })
}
//O(n**2) algo, but it is ok as N is very small and we do it only once ...
O(n**2) algo, but it is ok as N is very small and we do it only once
O ( n ** 2 ) algo but it is ok as N is very small and we do it only once
fn sanitize_overlaping(args: &[(usize, Box<dyn IArgLeaf>)], size: usize) -> bool {
    args
        .iter()
        .enumerate()
        .any(|(ind, arg_couple)| {
            let range: Range<usize> = arg_couple.0..arg_couple.0+arg_couple.1.size();
            if range.end > size {
                panic!("ArgComposite oversized with leafs {} vs {}", size, range.end);
            }
            args[ind+1..]
                .iter()
                .any(|&(start, ref arg)| {
                    if range.start >= start + arg.size() || range.end <= start {
                        false
                    } else {
                        println!("overlap in [ {} vs {} ] => {} {} -> {} {}",
                                arg_couple.1.name(), arg.name(),
                                range.start, range.end,
                                start, start + arg.size());
                        true
                    }
                })
        })
}
fn sanitize_overlaping ( args : & [ ( usize , Box < dyn IArgLeaf > ) ] , size : usize ) -> bool { args . iter ( ) . enumerate ( ) . any ( | ( ind , arg_couple ) | { let range : Range < usize > = arg_couple . 0 .. arg_couple . 0 + arg_couple . 1 . size ( ) ; if range . end > size { panic ! ( " " size range end ) ; } args [ ind + 1 .. ] . iter ( ) . any ( | & ( start , ref arg ) | { if range . start >= start + arg . size ( ) || range . end <= start { false } else { println ! ( " " arg_couple 1 name ( ) arg name ( ) range start range end start start arg size ( ) ) ; true } } ) } ) }
O(n**2) algo, but it is ok as N is very small and we do it only once ...
O ( n ** 2 ) algo but it is ok as N is very small and we do it only once ...
args
&[(usize, Box<dyn IArgLeaf>)]
size
usize
args
&[(usize, Box<dyn IArgLeaf>)]
size
usize