summaryrefslogtreecommitdiffstats
path: root/tests/ui/str/str-idx.rs
blob: 1b32ed5533d35279bb086b1851e65477c3610a98 (plain)
1
2
3
4
5
6
7
pub fn main() {
    let s: &str = "hello";
    let _: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}`
    let _ = s.get(4); //~ ERROR the type `str` cannot be indexed by `{integer}`
    let _ = s.get_unchecked(4); //~ ERROR the type `str` cannot be indexed by `{integer}`
    let _: u8 = s['c']; //~ ERROR the type `str` cannot be indexed by `char`
}