# WordSegment

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/text_formatting/unicode/struct-wordsegment/

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

```rust
struct WordSegment<'a>
```

Represents a segment between two Unicode word boundaries.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/text_formatting/unicode/word_segment.rs#L3)

## Members

- [`new`](#function-new)
- [`with_text`](#function-with_text)
- [`offset`](#function-offset)
- [`length`](#function-length)
- [`codepoint_offset`](#function-codepoint_offset)
- [`codepoint_length`](#function-codepoint_length)
- [`text`](#function-text)

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

### new

```rust
const fn new(offset: usize, length: usize, codepoint_offset: usize, codepoint_length: usize) -> Self
```

Initializes a new instance of the `WordSegment` struct.

* `offset` - The segment offset in UTF-16 code units.
* `length` - The segment length in UTF-16 code units.
* `codepoint_offset` - The segment offset in Unicode code points.
* `codepoint_length` - The segment length in Unicode code points.

Segments created through this constructor carry no `WordSegment::text` slice.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/text_formatting/unicode/word_segment.rs#L20)

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

### with_text

```rust
const fn with_text(offset: usize, text: &'a [u16], codepoint_offset: usize, codepoint_length: usize) -> Self
```

Initializes a new instance of the `WordSegment` struct.

* `offset` - The segment start offset in UTF-16 code units within the source span.
* `text` - The slice of the source span that makes up this segment.
* `codepoint_offset` - The segment offset in Unicode code points.
* `codepoint_length` - The segment length in Unicode code points.

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

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

### offset

```rust
const fn offset(self: &Self) -> usize
```

Gets the segment offset in UTF-16 code units.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/text_formatting/unicode/word_segment.rs#L36)

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

### length

```rust
const fn length(self: &Self) -> usize
```

Gets the segment length in UTF-16 code units.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/text_formatting/unicode/word_segment.rs#L42)

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

### codepoint_offset

```rust
const fn codepoint_offset(self: &Self) -> usize
```

Gets the segment offset in Unicode code points.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/text_formatting/unicode/word_segment.rs#L48)

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

### codepoint_length

```rust
const fn codepoint_length(self: &Self) -> usize
```

Gets the segment length in Unicode code points.

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

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

### text

```rust
const fn text(self: &Self) -> &'a [u16]
```

Gets the text content of this segment as a slice of the source span.

Empty for segments created through the constructor that takes a code-unit length
instead of a slice, whose source span is unknown. Use `WordSegment::length` when the
segment may come from an arbitrary caller rather than from the word break enumerator.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/text_formatting/unicode/word_segment.rs#L64)

## 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`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Copy`
- `Debug`
- `Default`
- `StructuralPartialEq`
- `PartialEq`
- `Eq`

## Availability

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