Skip to main content

ClassDefaults

Trait ClassDefaults 

Source
pub trait ClassDefaults {
    // Provided method
    fn static_constructor() { ... }
}
Expand description

What a type declares when it declares nothing: no default constructor, no interface casts, no properties and an empty static constructor.

The class macros read the declarations of a type through the names below. A type that declares one of them does so with an inherent item of the same name (written by hand for static_constructor, generated by ferro_properties! and [ferro_class_info!] for the others), which takes precedence over this trait; every other type falls back to it.

Provided Methods§

Source

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides).

A class declares it as an inherent function in the module of its ferro_class!:

ⓘ
impl Border {
    fn static_constructor() {
        Self::affects_render::<Border>(&[Self::background_property().as_property()]);
    }
}

It is never called by hand: the class initialisation calls it. Use Border::TYPE.ensure_class_init() to force the initialisation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§