@@ -2,8 +2,6 @@ use core::hash::{BuildHasher, Hash};
2
2
3
3
use super :: { Bucket , Entries , Equivalent , IndexMap } ;
4
4
5
- pub struct PrivateMarker { }
6
-
7
5
/// Opt-in mutable access to keys.
8
6
///
9
7
/// These methods expose `&mut K`, mutable references to the key as it is stored
@@ -16,7 +14,9 @@ pub struct PrivateMarker {}
16
14
/// implementing PartialEq, Eq, or Hash incorrectly would be).
17
15
///
18
16
/// `use` this trait to enable its methods for `IndexMap`.
19
- pub trait MutableKeys {
17
+ ///
18
+ /// This trait is sealed and cannot be implemented for types outside this crate.
19
+ pub trait MutableKeys : private:: Sealed {
20
20
type Key ;
21
21
type Value ;
22
22
@@ -47,12 +47,6 @@ pub trait MutableKeys {
47
47
fn retain2 < F > ( & mut self , keep : F )
48
48
where
49
49
F : FnMut ( & mut Self :: Key , & mut Self :: Value ) -> bool ;
50
-
51
- #[ doc( hidden) ]
52
- /// This method is not useful in itself – it is there to “seal” the trait
53
- /// for external implementation, so that we can add methods without
54
- /// causing breaking changes.
55
- fn __private_marker ( & self ) -> PrivateMarker ;
56
50
}
57
51
58
52
/// Opt-in mutable access to keys.
88
82
{
89
83
self . retain_mut ( keep)
90
84
}
85
+ }
91
86
92
- fn __private_marker ( & self ) -> PrivateMarker {
93
- PrivateMarker { }
94
- }
87
+ mod private {
88
+ pub trait Sealed { }
89
+
90
+ impl < K , V , S > Sealed for super :: IndexMap < K , V , S > { }
95
91
}
0 commit comments