Learning rust language is tough for me, so record practice here.
climbing/
┣ docs
┃ ┗ strings.md
┃ ┗ foo.md
┃ ┗ ...
┃
┣ src
┃ ┗ modules
┃ ┗ strings.rs
┃ ┗ foo.rs
┃ ┗ ...
┃
┃ ┗ modules.rs
┃ ┗ main.rs
main.rs
mod modules;
use modules::strings::qstring;
fn main() {
let quote = qstring("Learning rust language is tough for me, so record practice here");
println!("{}", quote);
}
...
modules.rs
pub mod strings;
...
modules/strings.rs
/// Create String from &str directly
pub fn qstring(str: &str) -> String {
String::from(str)
}
...
- Install rust in your local follow this guide (Note: this repository uses the rust package manager Cargo)
- Clone this repository to your local
- Reference and use modules in
main.rs
- Cd the root dir
- Run
cargo run
command
For example, docs/foo.md
is the note of the code src/modules/foo.rs
of the content Foo in Rust lang.
Contents | Docs | Modules |
---|---|---|
String | strings.md | strings.rs |
Variables and Mutability | variables_mutability.md | variables_mutability.rs |