LoginSignup
9
1

More than 3 years have passed since last update.

ソースの一部をrustfmtしたくないとき

Last updated at Posted at 2019-07-02

初めに

clapで愚直に設定を書くときに活用しているOSSがあったのでメモ
階層構造にしない方が、見やすい場合に便利です

やり方

#[rustfmt::skip]アノテーションを使う

サンプル

お好みで手で整形して、アノテーションを使ってrustfmtの整形対象外とする
範囲はこの場合fn parse_options関数全体にかかります

#[rustfmt::skip]
fn parse_options<'a>(options: &'a ArgMatches) -> CoolToolOptions<'a> {
    CoolToolOptionsBuilder::default()
        .expect(options.values_of("expect").map(|x| x.collect::<Vec<_>>().join(",")),)
        .cmd_prompt(options.values_of("cmd-prompt").and_then(|vals| vals.last()))
        .multi(if options.is_present("no-multi") {
            false
        } else {
            options.is_present("multi")
        })
        .bind(options.values_of("bind").map(|x| x.collect::<Vec<_>>()).unwrap_or_default(),)
        .build()
        .unwrap()
}

参考

github.com/lotabout/skim

9
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
1