Skip to main content

char_at

Function char_at 

Source
pub fn char_at(s: &str, index: usize) -> Option<char>
Expand description

Get character at specified index Similar to JavaScript’s String.prototype.charAt()

§Examples

use mudssky_utils::string::char_at;

assert_eq!(char_at("hello", 1), Some('e'));
assert_eq!(char_at("hello", 10), None);
assert_eq!(char_at("🦀", 0), Some('🦀'));