Add my own crates (correction: module)

i'm still new to Rust and already found servicing user input is cumbersome. i prefer user input like this

x = user_input()

instead of how it's currently done in Rust. i'll define a function and hide there the Rust way of accepting user input and call this function every time i need a user input. like having my own

#include <mySTL.h>

x = mySTL::user_input();

how does one do that in Rust?

Do you mean creating a module?

Consider this project structure:

- my_project/
  - Cargo.toml
  - src/

In your

mod input;

fn main() {
    let user_input = input::get_user_input();

If you're creating a command line tool, consider using clap.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.