Crate read_input[][src]

Expand description

How to use


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.


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.


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.

Working example


Module to be imported in the style use read_input::prelude::*; to get the essential functions and traits.

Collection of functions that make things a little less verbose.


‘builder’ used to store the settings that are used to fetch input.

‘builder’ used to store the settings that are used to fetch input.


Trait implemented by InputBuilder and InputBuilderOnce to standardize input settings.

A set of validation tests that use InputBuild::test under the hood.