From 930464c05e9e77a555ff2c8f43b5ac3537e8af24 Mon Sep 17 00:00:00 2001 From: Ben Williamson <12386+benw@users.noreply.github.com> Date: Thu, 11 Jun 2026 13:33:23 +1000 Subject: [PATCH] Remove ?Sized bound from Idx in Index and IndexMut `Idx: ?Sized` is useless because the trait methods pass the index by value, so it's impossible to impl with an unsized Idx type. Removing this makes it a little easier for learners to understand the intent of the Index and IndexMut traits. --- library/core/src/ops/index.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs index 2c62a3930c281..d12e301aa1da7 100644 --- a/library/core/src/ops/index.rs +++ b/library/core/src/ops/index.rs @@ -56,7 +56,7 @@ #[doc(alias = "[")] #[doc(alias = "[]")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] -pub const trait Index { +pub const trait Index { /// The returned type after indexing. #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "IndexOutput"] @@ -167,7 +167,7 @@ see chapter in The Book : [const] Index { +pub const trait IndexMut: [const] Index { /// Performs the mutable indexing (`container[index]`) operation. /// /// # Panics