[−][src]Function utf8_slice::slice
pub fn slice(s: &str, begin: usize, end: usize) -> &str
Fetches a slice of a string from a begin to an end index taking into account utf8/unicode character indices.
Arguments
s
- An input string to take the slice frombegin
- Where the slice beginsend
- Where the slice ends
Examples
let s = "The 🚀 goes to the 🌑!"; let rocket = utf8_slice::slice(s, 4, 5); // Will equal "🚀"
Note
- Will return an empty string for invalid indices *