WordSegment
struct · ferroui-base · v0.5.0
struct WordSegment<'a>
Represents a segment between two Unicode word boundaries.
Members
new
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.
with_text
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.
offset
const fn offset(self: &Self) -> usize
Gets the segment offset in UTF-16 code units.
length
const fn length(self: &Self) -> usize
Gets the segment length in UTF-16 code units.
codepoint_offset
const fn codepoint_offset(self: &Self) -> usize
Gets the segment offset in Unicode code points.
codepoint_length
const fn codepoint_length(self: &Self) -> usize
Gets the segment length in Unicode code points.
text
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.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafePropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedErasedDestructorIntoEitherCloneCopyDebugDefaultStructuralPartialEqPartialEqEq
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.