From c120199116439827a89a0ac0f24f91f99dbed60f Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Sat, 5 Jan 2019 05:56:23 +0300 Subject: Show suggestion to use .char().nth() and link to The Book on unimplemented Index trait --- src/libcore/ops/index.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/libcore') diff --git a/src/libcore/ops/index.rs b/src/libcore/ops/index.rs index 4f55c68ecd4..6cfa36741d0 100644 --- a/src/libcore/ops/index.rs +++ b/src/libcore/ops/index.rs @@ -51,6 +51,21 @@ /// ``` #[lang = "index"] #[rustc_on_unimplemented( + on( + _Self="&str", + note="you can use `.chars().nth()` or `.bytes().nth()` +see chapter in The Book " + ), + on( + _Self="str", + note="you can use `.chars().nth()` or `.bytes().nth()` +see chapter in The Book " + ), + on( + _Self="std::string::String", + note="you can use `.chars().nth()` or `.bytes().nth()` +see chapter in The Book " + ), message="the type `{Self}` cannot be indexed by `{Idx}`", label="`{Self}` cannot be indexed by `{Idx}`", )] @@ -141,6 +156,21 @@ pub trait Index { /// ``` #[lang = "index_mut"] #[rustc_on_unimplemented( + on( + _Self="&str", + note="you can use `.chars().nth()` or `.bytes().nth()` +see chapter in The Book " + ), + on( + _Self="str", + note="you can use `.chars().nth()` or `.bytes().nth()` +see chapter in The Book " + ), + on( + _Self="std::string::String", + note="you can use `.chars().nth()` or `.bytes().nth()` +see chapter in The Book " + ), message="the type `{Self}` cannot be mutably indexed by `{Idx}`", label="`{Self}` cannot be mutably indexed by `{Idx}`", )] -- cgit 1.4.1-3-g733a5