Wednesday, December 18, 2024

Rocking Rust

 Got going with using Rust, this morning. One creates the initial project on Command

Prompt, then asks VS Code to open it...                                                                      


                                                                                 


Decided to code in Rust from VS Code. One needs to install a rust extension, for me

this was Rust Analyser.

To get started, create a project folder from Command Prompt:

                                                                



Code gets written on the src: main file.

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

In the terminal, ask for: cargo run

                                                                         


Rust has been described as 'blazingly' fast; so I decided to give it a small task to perform.

My request to COPILOT:

Rust programming: could I see code, in Rust, that outputs 10 random numbers between 1 and 100 and outputs1-those numbers; 2- the difference between each number and the one following it with the first using 0 as a baseline. I would like to (later) use the output as data for a python heat map...

                                                                          

Needed to add a dependency to Cargo.toml:

rand = "0.8"

and do a save.

                                                                     

Ran cargo build, and then, cargo run on the terminal:

                                                                           

That was fast...                                                             





No comments: