1 // Check that we are flagged for ignoring `must_use` parallel adaptors. 2 // (unfortunately there's no error code for `unused_must_use`) 3 4 macro_rules! must_use { 5 ($( $name:ident #[$expr:meta] )*) => {$( 6 /// First sanity check that the expression is OK. 7 /// 8 /// ``` 9 /// #![deny(unused_must_use)] 10 /// 11 /// use rayon::prelude::*; 12 /// 13 /// let v: Vec<_> = (0..100).map(Some).collect(); 14 /// let _ = 15 #[$expr] 16 /// ``` 17 /// 18 /// Now trigger the `must_use`. 19 /// 20 /// ```compile_fail 21 /// #![deny(unused_must_use)] 22 /// 23 /// use rayon::prelude::*; 24 /// 25 /// let v: Vec<_> = (0..100).map(Some).collect(); 26 #[$expr] 27 /// ``` 28 mod $name {} 29 )*} 30 } 31 32 must_use! { 33 step_by /** v.par_iter().step_by(2); */ 34 chain /** v.par_iter().chain(&v); */ 35 chunks /** v.par_iter().chunks(2); */ 36 cloned /** v.par_iter().cloned(); */ 37 copied /** v.par_iter().copied(); */ 38 enumerate /** v.par_iter().enumerate(); */ 39 filter /** v.par_iter().filter(|_| true); */ 40 filter_map /** v.par_iter().filter_map(|x| *x); */ 41 flat_map /** v.par_iter().flat_map(|x| *x); */ 42 flat_map_iter /** v.par_iter().flat_map_iter(|x| *x); */ 43 flatten /** v.par_iter().flatten(); */ 44 flatten_iter /** v.par_iter().flatten_iter(); */ 45 fold /** v.par_iter().fold(|| 0, |x, _| x); */ 46 fold_with /** v.par_iter().fold_with(0, |x, _| x); */ 47 try_fold /** v.par_iter().try_fold(|| 0, |x, _| Some(x)); */ 48 try_fold_with /** v.par_iter().try_fold_with(0, |x, _| Some(x)); */ 49 inspect /** v.par_iter().inspect(|_| {}); */ 50 interleave /** v.par_iter().interleave(&v); */ 51 interleave_shortest /** v.par_iter().interleave_shortest(&v); */ 52 intersperse /** v.par_iter().intersperse(&None); */ 53 map /** v.par_iter().map(|x| x); */ 54 map_with /** v.par_iter().map_with(0, |_, x| x); */ 55 map_init /** v.par_iter().map_init(|| 0, |_, x| x); */ 56 panic_fuse /** v.par_iter().panic_fuse(); */ 57 positions /** v.par_iter().positions(|_| true); */ 58 rev /** v.par_iter().rev(); */ 59 skip /** v.par_iter().skip(1); */ 60 take /** v.par_iter().take(1); */ 61 update /** v.par_iter().update(|_| {}); */ 62 while_some /** v.par_iter().cloned().while_some(); */ 63 with_max_len /** v.par_iter().with_max_len(1); */ 64 with_min_len /** v.par_iter().with_min_len(1); */ 65 zip /** v.par_iter().zip(&v); */ 66 zip_eq /** v.par_iter().zip_eq(&v); */ 67 } 68