Rust on MAC from beginning

hello world!

Jimmy (xiaoke) Shen
2 min readOct 20, 2022
From [3]

Install from terminal[1]

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Test installation

test rust and cargo installation use the following command

jimmy@jimmys-MacBook-Pro ~ % cargo --versioncargo 1.64.0 (387270bc7 2022-09-16)

What is cargo?

Cargo is the Rust package manager. Cargo downloads your Rust package’s dependencies, compiles your packages, makes distributable packages, and uploads them to crates.io, the Rust community’s package registry. [2]

From [1]

Rust hello world

By following official [1]

  • Step 1:

We have a new folder named hello-rust and it has the following structure

  • Step 2: go to the hello-rust folder and run the code

Bingo, it works!

  • What is inside of main.rs?

quit simple, just println, should be short for printline. Looks like a combination of python and C++? fn is similar to def in python. There is no return type which is required by C++.

  • Check the folder content

This time, we got bunch of compiled files in the target folder, even some debug files. It is pretty interesting.

Let’s explore more next time!

Reference

Reference

[1] https://www.rust-lang.org/learn/get-started

[3] https://blog.logrocket.com/deep-dive-concurrency-rust-programming-language/

[2]https://doc.rust-lang.org/cargo/index.html

--

--

No responses yet