Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/james-see/rust-examples
Some examples of snippets I use a lot. Helped me get started and hope it will help others as well.
https://github.com/james-see/rust-examples
examples rust rust-language
Last synced: 27 days ago
JSON representation
Some examples of snippets I use a lot. Helped me get started and hope it will help others as well.
- Host: GitHub
- URL: https://github.com/james-see/rust-examples
- Owner: james-see
- License: gpl-3.0
- Created: 2018-07-27T22:33:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-04T19:11:18.000Z (over 6 years ago)
- Last Synced: 2024-10-12T00:31:54.493Z (3 months ago)
- Topics: examples, rust, rust-language
- Language: Rust
- Size: 1.7 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rust-examples
Some examples of snippets I use a lot. Helped me get started and hope it will help others as well.## Installing Rust
1. Run `curl https://sh.rustup.rs -sSf | sh`
2. then make sure Cargo is in your path by adding this to your profile: `export PATH="$HOME/.cargo/bin:$PATH"`. I use [oh-my-zsh](https://ohmyz.sh) so I just do `nano ~/.zshrc` then add that line to the bottom via CTRL + W and then CTRL + V to get to the bottom quickly, or you could just echo it to .zshrc via `echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc`.
## Running using `cargo build`
#### virtual manifest method
From the root folder simply run `cargo build` and it will build every sub directory package. Then explicitly run with `-p` the specific package you want to run, e.g., `cargo run -p tcp_server`.
#### Manual method
For each folder, cd into the folder and run `cargo build` then `cargo run` and it should work fine.
## Examples
_below are the examples in each subfolder under the main repo_
### tcp_server
Starts a local server on port 9123.
You can quickly netcat a message to it and it should respond back like this:
`echo 1 | netcat localhost 9123`
### input_output
A simple example where it asks for a number input and it prints out the number you selected.
### more coming soon