linzhengen / tech-notes

My tech notes write in github issues🧲
1 stars 0 forks source link

[20220729] RustでHello World! #165

Open linzhengen opened 2 years ago

linzhengen commented 2 years ago

... Current installation options:

default host triple: aarch64-apple-darwin default toolchain: stable (default) profile: default modify PATH variable: yes

1) Proceed with installation (default) 2) Customize installation 3) Cancel installation

info: profile set to 'default' info: default host triple is aarch64-apple-darwin info: syncing channel updates for 'stable-aarch64-apple-darwin' info: latest update on 2022-07-19, rust version 1.62.1 (e092d0b6b 2022-07-16) info: downloading component 'cargo' 4.0 MiB / 4.0 MiB (100 %) 3.9 MiB/s in 1s ETA: 0s info: downloading component 'clippy' info: downloading component 'rust-docs' 18.3 MiB / 18.3 MiB (100 %) 5.8 MiB/s in 3s ETA: 0s info: downloading component 'rust-std' 24.5 MiB / 24.5 MiB (100 %) 6.1 MiB/s in 4s ETA: 0s info: downloading component 'rustc' 51.8 MiB / 51.8 MiB (100 %) 6.3 MiB/s in 8s ETA: 0s info: downloading component 'rustfmt' info: installing component 'cargo' info: installing component 'clippy' info: installing component 'rust-docs' 18.3 MiB / 18.3 MiB (100 %) 3.2 MiB/s in 4s ETA: 0s info: installing component 'rust-std' 24.5 MiB / 24.5 MiB (100 %) 18.9 MiB/s in 2s ETA: 0s info: installing component 'rustc' 51.8 MiB / 51.8 MiB (100 %) 21.4 MiB/s in 2s ETA: 0s info: installing component 'rustfmt' info: default toolchain set to 'stable-aarch64-apple-darwin'

stable-aarch64-apple-darwin installed - rustc 1.62.1 (e092d0b6b 2022-07-16)

Rust is installed now. Great!

To get started you may need to restart your current shell. This would reload your PATH environment variable to include Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run: source "$HOME/.cargo/env"

- Updateしてみる

➜ ~ source "$HOME/.cargo/env" ➜ ~ rustup update info: syncing channel updates for 'stable-aarch64-apple-darwin' info: checking for self-updates

stable-aarch64-apple-darwin unchanged - rustc 1.62.1 (e092d0b6b 2022-07-16)

info: cleaning up downloads & tmp directories


- Hello World

➜ ~ mkdir hello-world-rust ➜ ~ cd hello-world-rust ➜ hello-world-rust vi main.rs fn main() { // 世界よ、こんにちは println!("Hello, world!"); } :wq ➜ hello-world-rust rustc main.rs ➜ hello-world-rust ls -1 main main.rs ➜ hello-world-rust ./main Hello, world!