[][src]Function utf8_slice::from

pub fn from(s: &str, begin: usize) -> &str

Fetches a slice of a string from a starting index taking into account utf8/unicode character indices.

Arguments

  • s - An input string to take the slice from
  • begin - Where the slice begins

Examples

let s = "The 🚀 goes to the 🌑!";

let rocket_goes_to_the_moon = utf8_slice::from(s, 4);
// Will equal "🚀 goes to the 🌑!"

Note

  • Will return an empty string for invalid indices *