Skip to content

Latest commit

 

History

History
98 lines (68 loc) · 2.47 KB

README.md

File metadata and controls

98 lines (68 loc) · 2.47 KB

101 Rust

Repository containing Rust code used for 101 Rust talk in CaceresTech meetup.

How to use

If you want to run the examples in your machine you need to have Rust installed. Use the official install Rust proceddure to do so if you still don't have it.

Once you have Rust in your machine, you have to go to each specific folder to run the code. This is the structure so far:

.
├── LICENSE
├── README.md
├── hello-world
└── modules
    ├── 01-basic-syntax
    ├── 02-control-flow
    ├── 03-ownership
    ├── 04-error-handling
    └── 05-testing

Hello world

A simple Hello world example that can be run just using cargo run:

$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/rust_101`

Hello, world!

Modules

Each module has a set of different examples to demonstrate different features of Rust as a programming language.

Examples can be run using the following command:

cargo run --example NAME_OF_THE_EXAMPLE

You can find the available examples for each module in the Cargo.toml of each module (e.g. modules/01-basic-syntax/Cargo.toml):

[package]
name = "basic-syntax"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[[example]]
name = "compound_types"

[[example]]
name = "references"

[[example]]
name = "slices"

[[example]]
name = "functions"

[[example]]
name = "types_inference"

For the testing module you need to follow a different approach:

cargo test --example NAME_OF_THE_EXAMPLE

Or to run the whole set of unit tests and integration tests:

cargo test

Bonus track

You can find a small demonstration project in bonus-track folder.

References