Cleanup: Remove ErrorMapper from all higher order operators in favor of using Into, once the never type stabilizes
- 主要語言
- Rust
- 星號
- 25
- 分支
- 2
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Since the inner observables, and the upstream error type can differ, and errors have to be able to go forward unless explicitly caught, a mapping between the two types have to be defined. Ideally, this would be a simple `.into()` transformation, but the current `Never` type, `Infallible` does not implement `impl From for T`, which could always be an `unreachable!()` for any `T`. But this is intentionally reserved for the [actual never type `!` once it stabilizes](https://github.com/rust-lang/rust/issues/35121).
This would allow cleaning up a lot of noisy `|_| unreachable!()` error mappers.
But currently the error mapper in higher order operators is a necessary evil. Without it,
a never erroring source of erroring observables is impossible to use with higher order operators.
```rs
// Where subject_1 and subject_2 has an error type of `MyError`
[subject_1, subject_2].into_observables().concat_all(); // Impossible: Infallible is not Into
```
#### Future Migration
In a future major release, once `!` stabilizes, the ErrorMapper will be removed, in favor of using `.into()` internally. Wherever actual error mapping is required, an additional `map_error` operator can be used. Uses of `Never::error_mapper()` (or manual definitions of `|_| unreachable!()`) can simply be removed.
#### Related Issues:
- https://github.com/AlexAegis/rx_bevy/issues/27
貢獻指南
評估
這個 Issue 還沒有評估資料。