# RegistrationHelper

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/struct-registrationhelper/

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

```rust
struct RegistrationHelper<'a, T: ?Sized + 'static>
```

Binds the service type `T` to an implementation; see
`FerroLocator::bind`.

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

## Members

- [`to_constant`](#function-to_constant)
- [`to_func`](#function-to_func)
- [`to_lazy`](#function-to_lazy)
- [`to_singleton`](#function-to_singleton)
- [`to_transient`](#function-to_transient)

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

### to_constant

```rust
fn to_constant(self: Self, constant: Rc<T>) -> &'a FerroLocator
```

Every lookup returns `constant`.

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

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

### to_func

```rust
fn to_func(self: Self, func: impl Fn() -> Option<Rc<T>> + 'static) -> &'a FerroLocator
```

Every lookup calls `func`.

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

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

### to_lazy

```rust
fn to_lazy(self: Self, func: impl Fn() -> Option<Rc<T>> + 'static) -> &'a FerroLocator
```

The first lookup calls `func`; later lookups return what it produced.

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

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

### to_singleton

```rust
fn to_singleton<TImpl: Default + 'static>(self: Self, upcast: fn(Rc<TImpl>) -> Rc<T>) -> &'a FerroLocator
```

The first lookup creates a `TImpl`, which every lookup then returns.

`upcast` converts the implementation handle to the service handle;
for a trait object service it is the identity closure
`|instance| instance`, which performs the unsizing coercion.

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

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

### to_transient

```rust
fn to_transient<TImpl: Default + 'static>(self: Self, upcast: fn(Rc<TImpl>) -> Rc<T>) -> &'a FerroLocator
```

Every lookup creates a new `TImpl`. See
`to_singleton` for `upcast`.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`

## Availability

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