Skip to main content

extends

Attribute Macro extends 

Source
#[extends]
Expand description

A limited form of class inheritance

For supported traits (see below), this macro implements missing trait methods as a wrapper over the same method on a specified base.

§Supported usage

§ThemeDraw

Attribute parameters:

ThemeDraw using Expr

This implements missing kas::theme::ThemeDraw methods over the specified base expression Expr. This expression is expected to yield an object implementing ThemeDraw. All applicable types should be in scope.

§Example
#[extends(ThemeDraw using self.base())]
impl ThemeDraw for Object {
    // ...
}

Since this example does not provide an implementation of fn image, this macro would provide the implementation below:

fn image(&mut self, id: ImageId, rect: Rect) {
    (self.base()).image(id, rect);
}

Each ThemeDraw method not implemented in the impl block is implemented by the macro in this manner.