LoginSignup
0
0

導入方法は上記のとおりです

わたしはWindows環境で、Rust環境はインストール済みであったため、
https://github.com/rust-lang/rustlings/?tab=readme-ov-file#windows
をコピペして、無事インストールできました

始める

rustlings watch

インストールが終わると、rustlings watchコマンドで、エクササイズを確認できます

すると、1回目は以下のような出力が出てきます
最近のプログラミング関係は、Astroとかもそうですが、CUIで遊び心がいっぱいですね

Progress: [------------------------------------------------------------] 0/96 (0.0 %)            ✓ Successfully ran exercises/intro/intro1.rs!

🎉 🎉  The code is compiling! 🎉 🎉

Output:
====================
Hello and
       welcome to...
                 _   _ _
  _ __ _   _ ___| |_| (_)_ __   __ _ ___  
 | '__| | | / __| __| | | '_ \ / _` / __| 
 | |  | |_| \__ \ |_| | | | | | (_| \__ \ 
 |_|   \__,_|___/\__|_|_|_| |_|\__, |___/ 
                               |___/      

This exercise compiles successfully. The remaining exercises contain a compiler
or logic error. The central concept behind Rustlings is to fix these errors and
solve the exercises. Good luck!

The source for this exercise is in `exercises/intro/intro1.rs`. Have a look!
Going forward, the source of the exercises will always be in the success/failure output.

If you want to use rust-analyzer, Rust's LSP implementation, make sure your editor is set        
up, and then run `rustlings lsp` before continuing.

====================

You can keep working on this exercise,
or jump into the next one by removing the `I AM NOT DONE` comment:

14 |  // hint.
15 |
16 |  // I AM NOT DONE
17 |
18 |  fn main() {
Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here.  

このエクササイズはうまく動くぜ。残りのエクササイズはコンパイルエラーとかロジックエラーがあるから、見つけて直してね!

このエクササイズのソースコードはexercises/intro/intro1.rsにあるから見てみてね!

みたいなことが書いてあります

後、rustlings watchで表示している状態で、エクササイズのソースコードを書き換えると、変更が反映されます(出力がリロードされる)

適当にprintln!で表示しているメッセージを変えてみたり、コンパイルエラーを仕込んだりして、挙動を確認してみました

さて、で、exercises/intro/intro2.rsから実際の作業を開始します

// intro2.rs
//
// Make the code print a greeting to the world.
//
// Execute `rustlings hint intro2` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

fn main() {
    println!("Hello {}!");
}

これを以下のように変更して、

-    println!("Hello {}!");
+    println!("Hello {}!", "World!");

以下の通り、出力結果を得られました
エクササイズはこれの繰り返しのようです

Output:
====================
Hello World!!

====================

エクササイズが終わったら、コメント文の// I AM NOT DONEを削除します
すると、watch出力が次のエクササイズへと移行します

まとめ

RustlingsをOptions付近まで遊んでみました

まだまだRustについての知見がないため、だいぶてこずったところが多かったです

ですが、ライブラリの使い方がわからない、ライブラリのメソッドに何があるかわからないという状態が多く、ここら辺は慣れでなんとかなるかなと思いました

開発環境、勉強環境とも充実しており、とっつきやすい言語だなという印象です

これから心がけることは

  • Rustを書くのに慣れるため、Exampleを実際に入力していく練習をする
  • ライブラリのリファレンスの調べ方を身につける

以上です

0
0
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
0
0