about
Bits Hello Rust
09/02/2023
0
Bits: Rust Hello
code, output, and build for Rust on Windows, macOS, and Linux
Synopsis:
This page demonstrates use of Visual Studio Code to build and execute a simple Rust "Hello World" program, showing its build process and launch file. The purpose is to show how to get started quickly.- Companion pages for Rust, C#, Python, and JavaScript are accessible from links in the left panel.
- Navigation through example levels for the same language is effected with the "Bits Pages" button in the left panel, or "Next" and "Prev" buttons in the menus or by using the "N" and "P" keys.
- The page links in the center of the left panel point to major sections of this page.
Note:
Most page links in this site refer to specific points in a target page, usually the top. For all of the code bits here, language links return to the last scroll position. This supports quickly moving between similar code for each of the languages covered, and maintains context for comparisons.
Most page links in this site refer to specific points in a target page, usually the top. For all of the code bits here, language links return to the last scroll position. This supports quickly moving between similar code for each of the languages covered, and maintains context for comparisons.
Source Code
// HelloWorld::main.rs
fn main() {
println!("Hello Rust world");
}
Output
C:\github\JimFawcett\Bits\Rust\rust_hello_world
> cargo run -q
Hello Rust world
C:\github\JimFawcett\Bits\Rust\rust_hello_world
>
Build
C:\github\JimFawcett\Bits\Rust\rust_hello_world
> cargo build
Compiling rust_hello_world v0.1.0 (C:\github\JimFawcett\Bits\Rust\rust_hello_world)
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
C:\github\JimFawcett\Bits\Rust\rust_hello_world
Create Project
C:\github\JimFawcett\test
> cargo new --bin rust_hello_world
Created binary (application) `rust_hello_world` package
C:\github\JimFawcett\test
> cd rust_hello_world
C:\github\JimFawcett\test\rust_hello_world
> dir
Directory: C:\github\JimFawcett\test\rust_hello_world
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2/23/2023 3:11 PM src
-a---- 2/23/2023 3:11 PM 185 Cargo.toml
C:\github\JimFawcett\test\rust_hello_world
> type Cargo.toml
[package]
name = "rust_hello_world"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
C:\github\JimFawcett\test\rust_hello_world
>
2.0 VS Code View
3.0 References
Reference | Description |
---|---|
Rust Story | E-book with seven chapters covering most of intermediate Rust |
Rust Bites | Relatively short feature discussions |
Bits Tooling | Tool chains, VS Code |