# cast_value

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/data/converters/function-cast_value/

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

```rust
fn cast_value<T: PropertyValue>(value: Option<&crate::BoxedValue>) -> Option<T>
```

Casts an untyped value to `T`: the equivalent of a type test followed by
a cast, where null is accepted by types that can be null.

A value casts to `T` if it is a `T`, if `T` is the "any value" type
(`Option<BoxedValue>` or [`BoxedValue`](/docs/0.5.0/api/ferroui-base/type_alias-boxedvalue/)), if `T` is the nullable form
(`Option<U>`) of the value's type, or if it is an object handle that
casts to the handle type `T`. Null casts to `Option<U>` and to
`Option<BoxedValue>`. A `&'static str` casts to `String`. No other
conversion (numeric, parsing, to text) is attempted.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/converters/func_value_converter.rs#L18)

## Availability

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