# RelativeScalar

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

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

```rust
struct RelativeScalar
```

Defines a scalar that may be defined relative to a containing element.

Equality treats NaN scalars as equal to each other.

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

## Members

- [`scalar`](#struct_field-scalar)
- [`unit`](#struct_field-unit)
- [`BEGINNING`](#assoc_const-beginning)
- [`MIDDLE`](#assoc_const-middle)
- [`END`](#assoc_const-end)
- [`new`](#function-new)
- [`equals`](#function-equals)
- [`to_value`](#function-to_value)
- [`parse`](#function-parse)

<a id="struct_field-scalar"></a>

### scalar

```rust
scalar: f64
```

The scalar.

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

<a id="struct_field-unit"></a>

### unit

```rust
unit: crate::RelativeUnit
```

The unit of the scalar.

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

<a id="assoc_const-beginning"></a>

### BEGINNING

```rust
const BEGINNING: RelativeScalar
```

The beginning of the containing element (0%).

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

<a id="assoc_const-middle"></a>

### MIDDLE

```rust
const MIDDLE: RelativeScalar
```

The middle of the containing element (50%).

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

<a id="assoc_const-end"></a>

### END

```rust
const END: RelativeScalar
```

The end of the containing element (100%).

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

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

### new

```rust
const fn new(scalar: f64, unit: RelativeUnit) -> Self
```



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

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

### equals

```rust
fn equals(self: &Self, other: RelativeScalar) -> bool
```



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

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

### to_value

```rust
fn to_value(self: &Self, size: f64) -> f64
```

Converts the scalar into a final value, using `size` as the size the scalar
is relative to.

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

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

### parse

```rust
fn parse(s: &str) -> Result<Self, FormatError>
```

Parses a `RelativeScalar` string: `"n"` (absolute) or `"n%"` (relative).

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- `ErasedDestructor`
- `IntoEither`
- `IInterpolator<RelativeScalar>`
- `From<RelativeScalar>`
- `ExpressionVariantValue`
- `ServerPropertyValue`
- `BatchValue`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)
- `Clone`
- `Copy`
- `Debug`
- `Default`
- `PartialEq`
- `FromStr`
- `Display`

## Availability

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