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