redox-os/orbtk

Cant define property with the same name as its type in widget!()

Opened this issue · 0 comments

Describe the bug
The widget!() macro is confused when i would like to define a property with the same name as its type.

To Reproduce
Run the following code:

use orbtk::prelude::*;

#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Layout {
    Grid,
    Table
}

widget!(
    LayoutChooser {
        layout: Layout
    }
);

impl Default for Layout {
    fn default() -> Self {
        Layout::Grid
    }
}

widget!(
    LayoutChooser {
        dir_view: u32,
        layout: Layout
    }
);

impl Template for LayoutChooser{
    fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
        self.name("LayoutChooser")
    }
}

The compiler refuses with :
expected struct Box, found struct LayoutChooser
help: store this in the heap by calling Box::new: Box::new(this.layout())

Expected behavior
Dont know its a bug or it is the intended behavior.
I worked around renaming the property.