Rust User Input
Links: 105 Rust Index
The prelude is the list of things that Rust automatically imports into every Rust program. It's kept as small as possible, and is focused on things, particularly traits, which are used in almost every single Rust program.
- Like we are able to print without importing anything.
- But user import is not included in prelude.
Crate in rust is synonymous to packages/libraries in other languages.
- In rust we import modules from crates.
- From these modules we can use specific functions in our code.
use std::io;. In this
stdis the crate and
iois the module.
- We are grabbing the
stdinfunction from the
- We have to pass the input variable like this because if we only pass input it will just pass the value. So by using the
&we passing the reference of input variable. But references are immutable so we include the keyword
Last updated: 2022-05-17