antoyo / relm

Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust
MIT License
2.42k stars 79 forks source link

Adds type hinting in connect! macro #219

Closed sanpii closed 3 years ago

sanpii commented 4 years ago

Fixes #194

This is a side-effect because the first form of the connect macro also works with Relm as 3rd argument.

I added a type hinting, I hope the error message is clear:

error[E0308]: mismatched types
  --> examples/menu.rs:55:9
   |
55 |         connect!(quit_item, connect_activate(_), self.model.relm, Quit);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `relm::component::Component`, found struct `relm::state::Relm`
   |
   = note: expected reference `&relm::component::Component<_>`
              found reference `&relm::state::Relm<Win>`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
antoyo commented 4 years ago

Sorry, I haven't had a chance to look at this yet.

antoyo commented 3 years ago

Sorry for the long delay.

I was wondering if we could remove one of the connect!'s macro branch instead of adding a type hint.

The first (look at the body in the connect_stream! macro here) and the third actually seem to have the exact same definition.

What do you think?

sanpii commented 3 years ago

Ok, if it’s the same, I agree to delete one.