#til an easy way to return iterators in Rust!
```rust
fn returns_an_iterator_of_string() -> impl Iterator<Item = String> {
// ...
}
```
-
Show this thread
-
is there a reason why
@rustlang doesn't infer that for me? Like@SwiftLang, both know what I'm aiming to return (only one return type per function, because of Hindley-Milner type system), so why both don't infer function types for me? is it for readability? perf?1 reply 0 retweets 2 likesShow this thread -
Replying to @galstar @SwiftLang
It’s a design choice. See here: https://users.rust-lang.org/t/why-can-lifetimes-not-be-inferred/25645/9 … (this is about lifetimes but it’s the same for types)
2 replies 0 retweets 1 like
(Beyond that, it also gives much better error messages)
3:34 AM - 5 May 2019
0 replies
0 retweets
2 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.