Xen / reference v0.1.0-demo.2
std.string
This topic is not available in the selected language or version. Showing the start of this section.
APIs documented for this release.
use std.string;| API | Result and purpose |
|---|---|
std.string.find(text: String, needle: String) | Option<Int>; first byte offset, or None |
std.string.contains(text: String, needle: String) | Bool; whether a match exists |
std.string.slice_bytes(text: String, start: Int, end: Int) | Result<String, BoundsError>; copy a range with an excluded end |
std.string.split_byte(text: String, separator: U8) | Vec<String>; split at a byte, keeping empty parts |
std.string.split_ascii_whitespace(text: String) | Vec<String>; split at ASCII whitespace, discarding empty parts |
std.string.is_ascii_whitespace(byte: U8) | Whether the byte is a space or in the range 9–13 |
String positions and lengths count bytes. An empty search string gives Some(0) from find and true from contains. slice_bytes requires 0 <= start <= end <= text.len(); otherwise it returns BoundsError.InvalidRange((start, end, length)). Splitting an empty string with split_byte gives one empty string.