如何访问Rust中字符串的第一个字符?

Ste*_*nko 5 rust

在JavaScript中,我写道:

s.charAt(0)
Run Code Online (Sandbox Code Playgroud)

什么会在Rust?我应该如何处理s.length == 0此案?

Fra*_*gné 13

使用s.chars().next().None如果字符串为空或Some(c)其他,则返回.