OxL Reference

type str

impl str

Since. 1.0.0-beta

Methods

oxlMockCalls(m: str) -> List<Call>
S.calls(.m) is rewritten by the compiler to "pkg.module.S".oxlMockCalls("m") (D-6106, D-7250).
len() -> usize
Length in bytes.
charCount() -> usize
Number of Unicode scalar values.
isEmpty() -> bool
Whether there are no bytes.
chars() -> List<char>
The chars (Unicode scalar values) in order.
bytes() -> List<u8>
The UTF-8 bytes in order.
contains(needle: str) -> bool
Whether needle occurs in the text.
startsWith(prefix: str) -> bool
Whether the text begins with prefix.
endsWith(suffix: str) -> bool
Whether the text ends with suffix.
find(needle: str) -> usize?
Byte index of the first occurrence of needle.
lower() -> str
The text in lower case (Unicode simple case mapping).
upper() -> str
The text in upper case (Unicode simple case mapping).
trim() -> str
The text without leading and trailing whitespace.
trimStart() -> str
The text without leading whitespace.
trimEnd() -> str
The text without trailing whitespace.
split(sep: str) -> List<str>
The pieces of the text between occurrences of sep (an empty piece for neighbouring separators); the text itself when sep does not occur.
splitWhitespace() -> List<str>
The words of the text
lines() -> List<str>
The lines of the text, without the line terminators (\n or \r\n).
replace(from: str, to: str) -> str
The text with every occurrence of from replaced by to.
repeat(n: usize) -> str
The text repeated n times.
slice(a: usize, b: usize) -> str
Substring of the byte range [a, b); panics unless both are char boundaries.
parse() -> T | ParseError
Parses the whole text as T (integer, float or bool); no surrounding whitespace is accepted.
rfind(needle: str) -> usize?
Byte index of the last occurrence of needle.
count(needle: str) -> usize
Number of non-overlapping occurrences of needle (0 for an empty needle).
trimPrefix(prefix: str) -> str
self without the leading prefix (unchanged if it does not start with it).
trimSuffix(suffix: str) -> str
self without the trailing suffix.
splitOnce(sep: str) -> (str, str)?
Splits at the first sep
replaceFirst(from: str, to: str) -> str
Replaces only the first occurrence.
padStart(width: usize, fill: char) -> str
Pads on the left with fill up to width characters.
padEnd(width: usize, fill: char) -> str
Pads on the right with fill up to width characters.
isBlank() -> bool
True when the text is empty or only white space.
eqIgnoreCase(other: str) -> bool
Equal after Unicode simple case mapping.
asciiLower() -> str
Lower-cases only A-Z (protocol tokens, header names).
parseInt() -> i64 | ParseError
Parses a decimal integer.
parseFloat() -> f64 | ParseError
Parses a decimal number.

Defined in: std/core/testing.oxl:279

See also