Sealed trait not implemented for &str

I am facing below error message:

error[E0277]: the trait bound &'a str: core::slice::private_slice_index::Sealed is not satisfied --> src/
681 | impl<'a> SliceIndex for &'a str {
| ^^^^^^^^^^^^^^^^ the trait core::slice::private_slice_index::Sealed is not implemented for &'a str

error: aborting due to previous error


impl<'a> SliceIndex for &'a str {
type Output=Json;

Looking up into the RFCs, mention something about gating traits from being implemented outside the crate so as to allow API evolution without breaking change. But I am able to implement SliceIndex<Json> for usize. So what is different between usize and &str.


There’s a “hidden” trait bound that you can see here.

This is likely done to control the types you can implement the trait for - you can see usize having an impl of the Sealed trait, implying it’s “blessed”:

1 Like

Thanks, I grep-ed rust source base for Sealed trait, but my local repo is couple of weeks old :). Will stick with Index trait. Cheers,