# Size

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

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

```rust
struct Size
```

Defines a size.

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

## Members

- [`width`](#struct_field-width)
- [`height`](#struct_field-height)
- [`INFINITY`](#assoc_const-infinity)
- [`new`](#function-new)
- [`aspect_ratio`](#function-aspect_ratio)
- [`parse`](#function-parse)
- [`constrain`](#function-constrain)
- [`deflate`](#function-deflate)
- [`equals`](#function-equals)
- [`nearly_equals`](#function-nearly_equals)
- [`inflate`](#function-inflate)
- [`with_width`](#function-with_width)
- [`with_height`](#function-with_height)
- [`deconstruct`](#function-deconstruct)

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

### width

```rust
width: f64
```

The width.

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

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

### height

```rust
height: f64
```

The height.

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

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

### INFINITY

```rust
const INFINITY: Size
```

A size representing infinity.

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

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

### new

```rust
const fn new(width: f64, height: f64) -> Self
```

Initializes a new instance of the `Size` structure.

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

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

### aspect_ratio

```rust
fn aspect_ratio(self: &Self) -> f64
```

Gets the aspect ratio of the size.

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

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

### parse

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

Parses a `Size` string (`"width, height"` or `"width height"`).

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

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

### constrain

```rust
fn constrain(self: &Self, constraint: Size) -> Size
```

Constrains the size: each dimension becomes the smaller of this size's and
the constraint's.

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

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

### deflate

```rust
fn deflate(self: &Self, thickness: Thickness) -> Size
```

Deflates the size by a `Thickness`. The result never has negative dimensions.

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

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

### equals

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

Returns a boolean indicating whether the size is equal to the other given
size (exact comparison of the dimensions).

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

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

### nearly_equals

```rust
fn nearly_equals(self: &Self, other: Size) -> bool
```

Returns a boolean indicating whether the size is equal to the other given
size (numerically, within a relative epsilon).

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

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

### inflate

```rust
fn inflate(self: &Self, thickness: Thickness) -> Size
```

Inflates the size by a `Thickness`.

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

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

### with_width

```rust
const fn with_width(self: &Self, width: f64) -> Size
```

Returns a new `Size` with the same height and the specified width.

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

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

### with_height

```rust
const fn with_height(self: &Self, height: f64) -> Size
```

Returns a new `Size` with the same width and the specified height.

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

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

### deconstruct

```rust
const fn deconstruct(self: &Self) -> (f64, f64)
```

Deconstructs the size into its width and height values.

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

## 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`
- [`Transition<Size>`](/docs/0.5.0/api/ferroui-base/animation/trait-transition/)
- `From<Size>`
- `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`
- `StructuralPartialEq`
- `PartialEq`
- `Default`
- `Mul<Vector>`
- `Div<Vector>`
- `Div`
- `Mul<f64>`
- `Div<f64>`
- `Add`
- `Sub`
- `AddAssign`
- `SubAssign`
- `MulAssign<f64>`
- `DivAssign<f64>`
- `MulAssign<Vector>`
- `DivAssign<Vector>`
- `FromStr`
- `Display`
- `Add<Thickness>`
- `Sub<Thickness>`
- `AddAssign<Thickness>`
- `SubAssign<Thickness>`

## Availability

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