Avoid indexing &str to be compatible with current rust master

Indexing &str has been removed from rust, instead we have to treat the
string as &[u8] using as_bytes() and index into that array.