fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #72883 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum49cae55760d

1.44.0
1.9 KiB43 linesraw
1error[E0277]: the type `str` cannot be indexed by `{integer}`
2  --> $DIR/str-idx.rs:3:17
3   |
4LL |     let _: u8 = s[4];
5   |                 ^^^^ string indices are ranges of `usize`
6   |
7   = help: the trait `std::slice::SliceIndex<str>` is not implemented for `{integer}`
8   = note: you can use `.chars().nth()` or `.bytes().nth()`
9           see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
10   = note: required because of the requirements on the impl of `std::ops::Index<{integer}>` for `str`
11
12error[E0277]: the type `str` cannot be indexed by `{integer}`
13  --> $DIR/str-idx.rs:4:19
14   |
15LL |     let _ = s.get(4);
16   |                   ^ string indices are ranges of `usize`
17   |
18   = help: the trait `std::slice::SliceIndex<str>` is not implemented for `{integer}`
19   = note: you can use `.chars().nth()` or `.bytes().nth()`
20           see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
21
22error[E0277]: the type `str` cannot be indexed by `{integer}`
23  --> $DIR/str-idx.rs:5:29
24   |
25LL |     let _ = s.get_unchecked(4);
26   |                             ^ string indices are ranges of `usize`
27   |
28   = help: the trait `std::slice::SliceIndex<str>` is not implemented for `{integer}`
29   = note: you can use `.chars().nth()` or `.bytes().nth()`
30           see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
31
32error[E0277]: the type `str` cannot be indexed by `char`
33  --> $DIR/str-idx.rs:6:17
34   |
35LL |     let _: u8 = s['c'];
36   |                 ^^^^^^ string indices are ranges of `usize`
37   |
38   = help: the trait `std::slice::SliceIndex<str>` is not implemented for `char`
39   = note: required because of the requirements on the impl of `std::ops::Index<char>` for `str`
40
41error: aborting due to 4 previous errors
42
43For more information about this error, try `rustc --explain E0277`.