fork/rust

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

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
2.6 KiB57 linesraw
1error[E0277]: the type `str` cannot be indexed by `{integer}`
2  --> $DIR/str-idx.rs:3:19
3   |
4LL |     let _: u8 = s[4];
5   |                   ^ string indices are ranges of `usize`
6   |
7   = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
8   = note: you can use `.chars().nth()` or `.bytes().nth()`
9           for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
10   = help: the trait `SliceIndex<[_]>` is implemented for `usize`
11   = help: for that trait implementation, expected `[_]`, found `str`
12   = note: required for `str` to implement `Index<{integer}>`
13
14error[E0277]: the type `str` cannot be indexed by `{integer}`
15  --> $DIR/str-idx.rs:4:19
16   |
17LL |     let _ = s.get(4);
18   |               --- ^ string indices are ranges of `usize`
19   |               |
20   |               required by a bound introduced by this call
21   |
22   = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
23   = note: you can use `.chars().nth()` or `.bytes().nth()`
24           for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
25   = help: the trait `SliceIndex<[_]>` is implemented for `usize`
26   = help: for that trait implementation, expected `[_]`, found `str`
27note: required by a bound in `core::str::<impl str>::get`
28  --> $SRC_DIR/core/src/str/mod.rs:LL:COL
29
30error[E0277]: the type `str` cannot be indexed by `{integer}`
31  --> $DIR/str-idx.rs:5:29
32   |
33LL |     let _ = s.get_unchecked(4);
34   |               ------------- ^ string indices are ranges of `usize`
35   |               |
36   |               required by a bound introduced by this call
37   |
38   = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
39   = note: you can use `.chars().nth()` or `.bytes().nth()`
40           for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
41   = help: the trait `SliceIndex<[_]>` is implemented for `usize`
42   = help: for that trait implementation, expected `[_]`, found `str`
43note: required by a bound in `core::str::<impl str>::get_unchecked`
44  --> $SRC_DIR/core/src/str/mod.rs:LL:COL
45
46error[E0277]: the type `str` cannot be indexed by `char`
47  --> $DIR/str-idx.rs:6:19
48   |
49LL |     let _: u8 = s['c'];
50   |                   ^^^ string indices are ranges of `usize`
51   |
52   = help: the trait `SliceIndex<str>` is not implemented for `char`
53   = note: required for `str` to implement `Index<char>`
54
55error: aborting due to 4 previous errors
56
57For more information about this error, try `rustc --explain E0277`.