Skip to content

Remove implicit error type conversion from Stream::fold #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

stepancheg
Copy link
Contributor

In my experience it does more harm than good: you need to specify
error type explicitly too often. See e. g. patched test case: it
fails before this commit.

stream.fold(0, |a, b| ok(a + b))

Without explicit error type parameter of ok, compilation fails with:

error[E0283]: type annotations required: cannot resolve `u32: std::convert::From<_>`
  --> tests/stream.rs:59:27
   |
59 |     assert_done(|| list().fold(0, |a, b| ok(a + b)), Ok(6));
   |                           ^^^^

In my experience it does more harm than good: you need to specify
error type explicitly too often. See e. g. patched test case: it
fails before this commit.

```
stream.fold(0, |a, b| ok(a + b))
```

Without explicit error type parameter of `ok`, compilation fails with:

```
error[E0283]: type annotations required: cannot resolve `u32: std::convert::From<_>`
  --> tests/stream.rs:59:27
   |
59 |     assert_done(|| list().fold(0, |a, b| ok(a + b)), Ok(6));
   |                           ^^^^
```
@alexcrichton
Copy link
Member

cc #291, an issue this is related to

This'll need to hold off merging until 0.2 regardless, but I'd personally be in favor as I've been bitten by these generics too many times.

@alexcrichton
Copy link
Member

Ok! Now that 0.2 is underway I was looking to merge this, but it looks like this has already happened in 0.2, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants