SMall Useful Rust Functions
Add this to your Cargo.toml
:
toml
[dependencies]
smurf = "0.2"
and this to your crate root:
rust
extern crate smurf;
```rust use smurf; use std::io::Write;
fn main() { print!("What is your name? "); std::io::stdout().flush().unwrap(); let username = input!(String); print!("What is your age? "); std::io::stdout().flush().unwrap(); let userage = input!(u8); let shelloutput = shell!("echo Hello {} of age {}", username, userage); // Returns ShellResult {code: i32, stdout: String, stderr: String} println!("Shell output: {}", shelloutput.stdout); println!("Shell stderr: {}", shelloutput.stderr); println!("Shell exit code: {}", shelloutput.code); } ```