スキップしてメイン コンテンツに移動

Rustで作るCLIツール

こんな感じで書いたら標準入力を受け取れる

fn main() {
   let mut s = String::new();
   std::io::stdin().read_line(&mut s).unwrap();

   // hello =>
   assert_eq!(s, "hello\n"); // 改行文字も含まれる
}

CLIツールを作るのに、Wantedlyの資料が分かりやすかった。

* Rust速習会2 - Speaker Deck https://speakerdeck.com/qnighy/rustsu-xi-hui-2

* Rust速習会3 - Speaker Deck https://speakerdeck.com/qnighy/rustsu-xi-hui-3

* Rust速習会4 - Speaker Deck https://speakerdeck.com/qnighy/rustsu-xi-hui-4