rust/src/test/ui/str/str-idx.stderr

44 lines
2.1 KiB
Plaintext
Raw Normal View History

2018-08-08 12:28:26 +00:00
error[E0277]: the type `str` cannot be indexed by `{integer}`
2018-12-25 15:56:47 +00:00
--> $DIR/str-idx.rs:3:17
2018-08-08 12:28:26 +00:00
|
LL | let _: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}`
| ^^^^ string indices are ranges of `usize`
2018-08-08 12:28:26 +00:00
|
= help: the trait `std::slice::SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
= note: required because of the requirements on the impl of `std::ops::Index<{integer}>` for `str`
2018-08-08 12:28:26 +00:00
error[E0277]: the type `str` cannot be indexed by `{integer}`
--> $DIR/str-idx.rs:4:15
|
LL | let _ = s.get(4); //~ ERROR the type `str` cannot be indexed by `{integer}`
| ^^^ string indices are ranges of `usize`
|
= help: the trait `std::slice::SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
error[E0277]: the type `str` cannot be indexed by `{integer}`
--> $DIR/str-idx.rs:5:15
|
LL | let _ = s.get_unchecked(4); //~ ERROR the type `str` cannot be indexed by `{integer}`
| ^^^^^^^^^^^^^ string indices are ranges of `usize`
|
= help: the trait `std::slice::SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
error[E0277]: the type `str` cannot be indexed by `char`
--> $DIR/str-idx.rs:6:17
|
LL | let _: u8 = s['c']; //~ ERROR the type `str` cannot be indexed by `char`
| ^^^^^^ string indices are ranges of `usize`
|
= help: the trait `std::slice::SliceIndex<str>` is not implemented for `char`
= note: required because of the requirements on the impl of `std::ops::Index<char>` for `str`
error: aborting due to 4 previous errors
2018-08-08 12:28:26 +00:00
For more information about this error, try `rustc --explain E0277`.