AlexAegis / AlexAegis/rx_bevy

Cleanup: Remove ErrorMapper from all higher order operators in favor of using Into, once the never type stabilizes

Offen
#26 0 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @AlexAegis Auf GitHub ansehen
blocked (rust) cleanup enhancement
Vorherrschende Sprache
Rust
Sterne
25
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.