antoyo / relm

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

Allow ::relm::Widget in relm_widget macro #106

Closed sanpii closed 6 years ago

sanpii commented 6 years ago

This is necessary when you called your widget Widget.

I tried to allow any type, but rustc isn’t aggree with my idea. Maybe my low experience with macro is the raison. At least it’s could be great to write the complete type name (::relm::Widget) in addition of Widget.

antoyo commented 6 years ago

I'm not sure what you're asking about? Can you please show me a code example what what you want and isn't working?

sanpii commented 6 years ago

Of, course. Here a patch for examples/buttons-derive/src/main.rs:

diff --git i/examples/buttons-derive/src/main.rs w/examples/buttons-derive/src/main.rs
index e5ef6f7..b918d3b 100644
--- i/examples/buttons-derive/src/main.rs
+++ w/examples/buttons-derive/src/main.rs
@@ -33,7 +33,6 @@ use gtk::{
     WidgetExt,
 };
 use gtk::Orientation::Vertical;
-use relm::Widget;

 pub struct Model {
     counter: i32,
@@ -48,7 +47,7 @@ pub enum Msg {

 // An alternative to the #[widget] attribute which works on stable.
 relm_widget! {
-    impl Widget for Win {
+    impl ::relm::Widget for Win {
         // The initial model.
         fn model() -> Model {
             Model {

And the compilation error:

error: no rules expected the token `::`
  --> src/main.rs:50:10
   |
50 |     impl ::relm::Widget for Win {
   |          ^^
antoyo commented 6 years ago

Could you please open a PR that updates this line accordingly? I guess that would fix this issue. Thanks in advance.