Expand description
§How to use
Add
read_input = "0.8"to your cargo.toml under [dependencies] and add
use read_input::prelude::*;to your main file.
You can get input with.
input::<Type>().get();Where Type is the type you want.
You can use all types that implement std::str::FromStr.
This currently includes the standard library types isize, usize, i8, u8, i16, u16, f32, i32, u32, f64, i64, u64, i128, u128, char, Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6 and String.
Many crates also implement std::str::FromStr for their types.
For example, if you want to assign a valid unsigned 32bit value to a variable called input, you could write.
let input = input::<u32>().get();Rust can often work out the type. When this is the case you can skip explicitly stating the type.
input().get()The input() function uses a common pattern called the builder pattern.
Many settings can be use by adding methods between input() and get().
Available methods can be found on the InputBuild Trait;
§How to use with custom type
To use read_input with a custom type you need to implement std::str::FromStr for that type.
Modules§
- prelude
- Module to be imported in the style
use read_input::prelude::*;to get the essential functions and traits. - shortcut
- Collection of functions that make things a little less verbose.
Structs§
- Input
Builder - ‘builder’ used to store the settings that are used to fetch input.
- Input
Builder Once - ‘builder’ used to store the settings that are used to fetch input.
Traits§
- Input
Build - Trait implemented by InputBuilder and InputBuilderOnce to standardize input settings.
- Input
Constraints - A set of validation tests that use
InputBuild::testunder the hood.