# ClassDefaults

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/trait-classdefaults/

**trait** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
trait ClassDefaults
```

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.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/type_system.rs#L697)

## Members

- [`static_constructor`](#function-static_constructor)

<a id="function-static_constructor"></a>

### static_constructor

```rust
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!`:

```ignore
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.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/type_system.rs#L734)

## Trait implementations

- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
