Skip to main content

InquireLength

Trait InquireLength 

Source
pub trait InquireLength {
    // Required method
    fn inquire_length(&self) -> usize;
}
Expand description

Custom trait to call correct method to retrieve input length.

The method can vary depending on the type of input.

String inputs should count the number of graphemes, via .graphemes(true).count(), instead of the number of bytes via .len(). While simple slices should keep using .len()

Required Methods§

Source

fn inquire_length(&self) -> usize

String inputs should count the number of graphemes, via .graphemes(true).count(), instead of the number of bytes via .len(). While simple slices keep using .len()

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl InquireLength for &str

Source§

impl<T> InquireLength for &[T]

Implementors§