Crates.io | smurf |
lib.rs | smurf |
version | 0.3.1 |
source | src |
created_at | 2023-03-17 12:26:09.987037 |
updated_at | 2024-01-03 13:33:33.688441 |
description | SMall Useful Rust Functions |
homepage | |
repository | https://github.com/ivabus/smurf |
max_upload_size | |
id | 812662 |
size | 11,757 |
SMall Useful Rust Functions
Add this to your Cargo.toml
:
[dependencies]
smurf = "0.3"
and this to your crate root:
extern crate smurf;
use smurf;
use std::io::Write;
fn main() {
print!("What is your name? ");
std::io::stdout().flush().unwrap();
let user_name = input!(String);
print!("What is your age? ");
std::io::stdout().flush().unwrap();
let user_age = input!(u8);
let shell_output = shell!("echo Hello {} of age {}", user_name, user_age); // Returns ShellResult {code: i32, stdout: String, stderr: String}
println!("Shell output: {}", shell_output.stdout);
println!("Shell stderr: {}", shell_output.stderr);
println!("Shell exit code: {}", shell_output.code);
}