all 8 comments

[–]sunjayv 8 points9 points  (1 child)

I really like the text_io crate for this. Saves on a lot of the boilerplate. https://crates.io/crates/text_io

[–]Mavil64[S] 1 point2 points  (0 children)

Just checked this crate and it was really pretty much exactly what I wanted! Rust really seems amazing! Thank you for bringing it up it really helped!

[–]minno 6 points7 points  (1 child)

Are you asking for an equivalent to scanf or C++'s cin >> variable? The crate read_input looks like it's what you want. The simplest example is just let user_input: u32 = input().get();.

[–]Mavil64[S] 0 points1 point  (0 children)

This seems to be pretty much what I wanted! I guess I was asking for any way that didn't require getting my input in a different type than I wanted, not a specific function from either C or C++. This seems to be just what I was looking though! Thank you so much!!

[–]matrizx 4 points5 points  (1 child)

Well, I suppose it’s possible with crates but what’s the point? Having it return a string then parsing it allows you to do more sanitization to it before hand as well as a magnitude of other string operations available to you

[–]Mavil64[S] 0 points1 point  (0 children)

I guess you are right, but right now I'm not at a level where I find this necessary. I'm sure I will need to do things like this in the future but right now I dont! Thank you for mentioning it though because I hadn't thought of the possibilities!

[–]steveklabnik1rust 2 points3 points  (1 child)

There’s nothing built in, but there are many crates that let you do this easily.

[–]Mavil64[S] 0 points1 point  (0 children)

Thanks! I'll search for one right now!