Xen / reference v0.1.0-demo.2
std.string
선택한 언어나 버전에는 이 주제가 없어 같은 영역의 시작 페이지를 표시합니다.
이 릴리스에 문서화된 API를 정리합니다.
use std.string;| API | 결과와 사용법 |
|---|---|
std.string.find(text: String, needle: String) | Option<Int>; 첫 바이트 위치, 없으면 None |
std.string.contains(text: String, needle: String) | Bool; 포함 여부 |
std.string.slice_bytes(text: String, start: Int, end: Int) | Result<String, BoundsError>; 끝을 제외한 구간을 복사 |
std.string.split_byte(text: String, separator: U8) | Vec<String>; 구분 바이트로 분리, 빈 항목 유지 |
std.string.split_ascii_whitespace(text: String) | Vec<String>; ASCII 공백으로 분리, 빈 항목 제외 |
std.string.is_ascii_whitespace(byte: U8) | 공백 또는 바이트 9~13인지 확인 |
문자열 위치와 길이는 바이트 기준입니다. 검색어가 빈 문자열이면 find는 Some(0), contains는 true입니다. slice_bytes에는 0 <= start <= end <= text.len()이 필요합니다. 잘못된 범위는 BoundsError.InvalidRange((start, end, length))입니다. 빈 문자열을 split_byte로 나누면 빈 문자열 하나가 나옵니다.