#1: Setting Up a New Rust Project

Hopefully by now you're all setup and ready to build. Let's start simple and just setup our project.

If you have installed Rust correctly. You should start by running the following command:

cargo init rusty-db

In our case, we called our project rusty-db, but you can name it whatever you want. This command should generate the following directory for you.

📦rusty-db
 ┣ 📂src
 ┃ ┗ 📜main.rs
 ┗ 📜Cargo.toml

The Cargo.toml file includes your project settings including version, dependencies, name etc. At this point you can ignore that until we need it later.

Now let's take a look at main.rs 

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

Here we see a main function defined using the fn keyword. In Rust, like some other programming languages, your application needs a "main" entry point and without it, your program won't compile.

In our main function you can see that we are trying to print "Hello, world!" to our standard output. The println!() function is more powerful than the simple usage here. We will be using that more later.

Now let's compile our program. You can do this in several ways and depending on your needs.

If you just want to quickly run your application to validate it:

cargo run

This will build and compile your program. If you just want to build, but not run it:

cargo build

You can also use the following to build your program:

rustc <PATH_TO_MAIN.RS>

Although I don't recommend that if you're just starting out. Cargo is generally the more "friendly" way to go.

One last thing, if you prefer to use you're editor to run your application, I am sure you can find an extension for it. Since I use VS Code, I use the Rust Analyzer extension which provides tons of features including build/run.

After running one of the above commands, you should now see an executable file built for your system. If you run that file through your command line, you should see the classic:

Hello, world!

Hooray! now that you're all set up, in the next chapter, we start to actually implement the db. 

Stay tuned :)