Module compiler

string

Strings are immutable UTF-8 text. Offsets in this module are byte offsets, and s.len() is the length in bytes. Comparison needs no import: == compares contents and < orders by UTF-8 bytes.

format is how you build text from values; it is checked at compile time. For trimming, splitting, replacing and other text helpers, see the stdlib text module.

Built into the compiler.

Import what you use (use path::* is not allowed):

use string::{byte_at, find_from};

Functions#

NameDescription
byte_atReturns the byte at byte offset i of s, or -1 when i is out of range.
find_fromReturns the byte offset of the first needle in hay at or after start, or -1.
formatBuilds a string from the literal fmt and the arguments that follow it.
from_bytesDecodes bytes as UTF-8 text.
match_atReturns whether needle occurs in s starting exactly at byte offset at.
rfindReturns the byte offset of the last needle in hay, or -1.
slice_bytesReturns the part of s between byte offsets start (inclusive) and end (exclusive).
to_bytesEncodes s as UTF-8 into a new Vec<byte>.
↑ ↓ navigate ↵ open