# FuncDataTemplate

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/templates/struct-funcdatatemplate/

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

```rust
struct FuncDataTemplate
```

Builds a control for a piece of data.

The typed constructors (`for_type` and friends) take
the place of the generic class of the same name: they match data that can
be cast to `T`, and null data when `T` accepts null.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/templates/func_data_template.rs#L15)

## Members

- [`default_template`](#function-default_template)
- [`access`](#function-access)
- [`new`](#function-new)
- [`for_type`](#function-for_type)
- [`for_type_with_match`](#function-for_type_with_match)

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

### default_template

```rust
fn default_template() -> Rc<FuncDataTemplate>
```

The default data template used in the case where no matching data
template is found.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/templates/func_data_template.rs#L61)

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

### access

```rust
fn access() -> Rc<FuncDataTemplate>
```

The implementation of `default_template`
for data that displays an access key.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/templates/func_data_template.rs#L67)

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

### new

```rust
fn new(match_: impl Fn(Option<&BoxedValue>) -> bool + 'static, build: impl Fn(&Option<BoxedValue>, &NameScopeRef) -> Option<Ref<Control>> + 'static, supports_recycling: bool) -> Rc<Self>
```

Creates a data template.

`match_` determines whether the data template matches the specified
data and `build` returns a control when supplied with data matching
the template and the name scope of the built content.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/templates/func_data_template.rs#L76)

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

### for_type

```rust
fn for_type<T: 'static>(build: impl Fn(&T, &NameScopeRef) -> Option<Ref<Control>> + 'static, supports_recycling: bool) -> Rc<Self>
```

Creates a data template that matches data of type `T`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/templates/func_data_template.rs#L85)

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

### for_type_with_match

```rust
fn for_type_with_match<T: 'static>(match_: impl Fn(&T) -> bool + 'static, build: impl Fn(&T, &NameScopeRef) -> Option<Ref<Control>> + 'static, supports_recycling: bool) -> Rc<Self>
```

Creates a data template that matches data of type `T` accepted by
`match_`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/templates/func_data_template.rs#L94)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- [`ITemplateWithParam<Option<Rc<dyn AnyValue>>, Option<Ref<Control>>>`](/docs/0.5.0/api/ferroui-controls/templates/trait-itemplatewithparam/)
- [`IDataTemplate`](/docs/0.5.0/api/ferroui-controls/templates/trait-idatatemplate/)
- [`IRecyclingDataTemplate`](/docs/0.5.0/api/ferroui-controls/templates/trait-irecyclingdatatemplate/)

## Availability

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