rayon-rs/rayon

A `#[parallelized]` attribute

オープン

#553 opened on 2018/03/12

 (10 件のコメント) (38 件のリアクション) (0 人の担当者)Rust (450 件のフォーク)batch import
enhancementhelp wanted

Repository metrics

Stars
 (9,410 個のスター)
PR merge metrics
 (平均マージ 9m) (30d で 2 merged PRs)

説明

Once custom attributes are stable, I think it would be great to have an attribute that transforms a for loop into a parallel iterator for_each call:

#[parallelized]
for x in 0..100 {
    println!("{}", x);
}

Equivalent to:

(0..100).into_par_iter().for_each(|x| println!("{}", x));

This would be analogous to futures-await's #[async] attribute, which generates a for loop that processes a Stream.

The one nit would be that early returns would be a mistake, hopefully a compiler error, and you would probably want to do what you can to catch them while expanding the attribute.

コントリビューターガイド