4 ms·
That’s not a datatype... That’s an iterater returned by calling .split_whitespace() on a string. Basically the same as calling .split(‘ ‘) on a string in JavaS
by jayflux 9y ago
That’s not a datatype...
That’s an iterater returned by calling .split_whitespace() on a string.
Basically the same as calling .split(‘ ‘) on a string in JavaScript
You can find a list of Rusts primitive types here:
https://doc.rust-lang.org/std/#primitives https://doc.rust-lang.org/std/#primitives
- lucozade 9y ago> That’s not a datatype It's a named struct. That's pretty datatype-y. I don't agree with the GP that this is an example of overengineering. If anything it's an example of current Rust being slightly underengineered. Presumably a lot of these temporary types can be killed off once `impl Trait` goes mainstream?
- the_mitsuhiko 9y agoI would never want the named types to go away. They heavily improve the error messages you get.
- twic 9y agoIt's a datatype, but it's an implementation detail - str::split_whitespace has to return something that implements the Iterator trait, so it return this. You as a programmer should never need to name it explicitly. When "impl Trait" lands, it will be possible to hide details like this.
- leshow 9y agoI asked this question on IRC and they said that it likely wouldn't go away. There may be a couple reasons, backwards compatibility for one, the other may be that when the type is existentially quantified the compiler has to search for a matching implementation, that search can take time. We want stuff using std to compile fast.