SHARE
TWEET

Untitled

a guest Aug 25th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn do_something<T, S>(params: &[S], subs: &[T])
  2. where
  3.     T: Clone + core::slice::SliceIndex<[S]>,
  4.     <T as core::slice::SliceIndex<[S]>>::Output: core::fmt::Debug,
  5.     S: core::fmt::Debug,
  6. {
  7.     for range in subs {
  8.         println!("Sequence: {:?}", &params[range.clone()]);
  9.     }
  10.     println!("Unsliced: {:?}", params);
  11. }
  12.  
  13. fn main() {
  14.     let mut params = vec![];
  15.     let mut idx = vec![];
  16.     let mut global_idx = 0;
  17.     for seq in &[vec![0], vec![4, 3], vec![38, 2, 1, 255, 100]] {
  18.         let start = global_idx;
  19.         for p in seq {
  20.             params.push(*p);
  21.             global_idx += 1;
  22.         }
  23.         idx.push(start..global_idx);
  24.     }
  25.     do_something(&params, &idx);
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top