https://github.com/nerdalert/rust-examples
A collection of Rust examples for learning Rust
https://github.com/nerdalert/rust-examples
Last synced: 12 months ago
JSON representation
A collection of Rust examples for learning Rust
- Host: GitHub
- URL: https://github.com/nerdalert/rust-examples
- Owner: nerdalert
- License: wtfpl
- Created: 2019-12-15T20:47:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-09-13T18:44:32.000Z (almost 4 years ago)
- Last Synced: 2025-06-11T13:58:56.309Z (about 1 year ago)
- Language: Rust
- Size: 74.2 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rust-examples
A collection of Rust examples for learning Rust for beginners to start getting a feel for Rust. I have recently started playing around with Rust and wanted to post code snippets for the basic concepts and mechanics for those who learn by hacking like I do.
# Install Rust
The only prerequisite is to have Rust installed on your machine. Install it with the following commands:
```
# Download and install Rust
curl https://sh.rustup.rs -sSf | sh
source ~/.cargo/env
# You can test the installtion with the following
cargo new rust1 --bin
cd rust1/
cargo run ./
```
# Clone the repo and run the example snippets
To get started with the snippets, simply clone the repo:
```
git clone https://github.com/nerdalert/rust-examples.git
cd rust-examples
```
Then cd into any of the directories and run the app with `cargo run`
- Below is an example of how to run the code in this repo:
```
(='o'=) [rust-examples]$ cd hashmap
(='o'=) [hashmaps]$ cargo run
Compiling hashmaps v0.1.0 (/Users/brent/rust/tutorials-brent/hashmaps)
Finished dev [unoptimized + debuginfo] target(s) in 0.57s
Running `target/debug/hashmaps`
Server count -> 4
The IP for server1 is -> "172.17.0.10"
The new IP for server1 is -> "192.168.200.40"
server1 : 192.168.200.40
server3 : 10.100.10.20
server4 : 10.200.10.30
server2 : 192.168.100.10
```
Happy hacking family!