ui_controls

module std::textsource

Searching and parsing byte text.

These extend &[u8], the type every text-taking function and string literal uses, so they apply to a String through its view(): line.view().starts_with(&"#"). Searches scan for the needle's first byte and compare the rest only where it matches.

fn starts_withsource

exp fn starts_with(self text: &[u8], prefix: &[u8]) -> bool

True when the text begins with the prefix.

fn ends_withsource

exp fn ends_with(self text: &[u8], suffix: &[u8]) -> bool

True when the text ends with the suffix.

fn findsource

exp fn find(self text: &[u8], needle: &[u8], from: u64) -> Option<u64>

Where the needle first occurs at or after from, or None. An empty needle occurs at from itself.

fn find_bytesource

exp fn find_byte(self text: &[u8], byte: u8, from: u64) -> Option<u64>

Where the byte first occurs at or after from, or None.

fn containssource

exp fn contains(self text: &[u8], needle: &[u8]) -> bool

True when the needle occurs in the text.

fn trimsource

exp fn trim(self text: &[u8]) -> &[u8]

The text without the spaces, tabs, carriage returns and newlines at either end.

fn parse_integersource

exp fn parse_integer(self text: &[u8]) -> Option<i64>

The decimal integer the whole text spells, with an optional leading '-' or '+', or None when it spells none or one out of range.