//#[inline] fn reverse(slice: &mut [T]) { match slice { [ref mut a, ref mut rest @ .., ref mut b] => { std::mem::swap(a, b); reverse(rest) }, [] | [_] => (), } } /// This actually works! And is so easily parallelisable with something like rayon, or asyncing by spawning/creating the tail-call into a new task, then either waiting them concurrently or in parallen (spawn or created future from just calling the function without awaiting it) #[allow(dead_code)] fn binsearch<'a, V: ?Sized, T: PartialEq + 'a>(slice: &'a [T], find: &V) -> Option<&'a T> { match slice { [ref a, pivot @ .., ref b] => { match (a==find, b==find) { (true, _) => Some(a), (_, true) => Some(b), _ => binsearch(pivot, find), } }, [ref a] if a == find => Some(a), _ => None, } } fn main() { let mut args: Vec = std::env::args().skip(1).collect(); reverse(&mut args[..]); //eprintln!("{:?}", binsearch(&args[..], "1")); // It works! #[cfg(feature="output-lines")] { for x in args.iter() { #[cfg(feature="output-quoted")] println!("{:?}", x); #[cfg(not(feature="output-quoted"))] println!("{}", x); } } #[cfg(not(feature="output-lines"))] println!("{:?}", args); }