Crates.io | scanf |
lib.rs | scanf |
version | 1.2.1 |
source | src |
created_at | 2021-11-27 23:17:28.120332 |
updated_at | 2021-12-12 02:09:23.552909 |
description | Parse text inputs (inverse of print! and format!) |
homepage | |
repository | https://github.com/jhg/scanf-rs |
max_upload_size | |
id | 488573 |
size | 24,615 |
If you know it from C, same functionality but with memory safety.
let mut number: u32 = 0;
let mut name: String = String::new();
if scanf!("{},{}", number, name).is_ok() {
println!("Input is: {} and {}", number, name);
}
let input = "5,something";
let mut number: u32 = 0;
let mut name: String = String::new();
if let Err(error) = sscanf!(input, "{},{}", number, name) {
panic!("Error {} using sscanf!", error);
}
Look more examples in the documentation.