@@ -738,36 +738,6 @@ impl DictKey for Py<PyStr> {
738738 }
739739}
740740
741- impl DictKey for PyStrRef {
742- type Owned = Self ;
743- #[ inline]
744- fn _to_owned ( & self , _vm : & VirtualMachine ) -> Self :: Owned {
745- self . clone ( )
746- }
747-
748- fn key_hash ( & self , vm : & VirtualMachine ) -> PyResult < HashValue > {
749- Ok ( self . hash ( vm) )
750- }
751-
752- fn key_is ( & self , other : & PyObject ) -> bool {
753- self . is ( other)
754- }
755-
756- fn key_eq ( & self , vm : & VirtualMachine , other_key : & PyObject ) -> PyResult < bool > {
757- if self . is ( other_key) {
758- Ok ( true )
759- } else if let Some ( pystr) = str_exact ( other_key, vm) {
760- Ok ( pystr. as_str ( ) == self . as_str ( ) )
761- } else {
762- vm. bool_eq ( self . as_object ( ) , other_key)
763- }
764- }
765-
766- fn key_as_isize ( & self , vm : & VirtualMachine ) -> PyResult < isize > {
767- self . as_object ( ) . key_as_isize ( vm)
768- }
769- }
770-
771741impl DictKey for PyRefExact < PyStr > {
772742 type Owned = Self ;
773743 #[ inline]
@@ -793,39 +763,6 @@ impl DictKey for PyRefExact<PyStr> {
793763
794764/// Implement trait for the str type, so that we can use strings
795765/// to index dictionaries.
796- impl DictKey for & str {
797- type Owned = String ;
798- #[ inline]
799- fn _to_owned ( & self , _vm : & VirtualMachine ) -> Self :: Owned {
800- ( * * self ) . to_owned ( )
801- }
802-
803- fn key_hash ( & self , vm : & VirtualMachine ) -> PyResult < HashValue > {
804- // follow a similar route as the hashing of PyStrRef
805- Ok ( vm. state . hash_secret . hash_str ( * self ) )
806- }
807-
808- fn key_is ( & self , _other : & PyObject ) -> bool {
809- // No matter who the other pyobject is, we are never the same thing, since
810- // we are a str, not a pyobject.
811- false
812- }
813-
814- fn key_eq ( & self , vm : & VirtualMachine , other_key : & PyObject ) -> PyResult < bool > {
815- if let Some ( pystr) = str_exact ( other_key, vm) {
816- Ok ( pystr. as_str ( ) == * self )
817- } else {
818- // Fall back to PyObjectRef implementation.
819- let s = vm. ctx . new_str ( * self ) ;
820- s. key_eq ( vm, other_key)
821- }
822- }
823-
824- fn key_as_isize ( & self , vm : & VirtualMachine ) -> PyResult < isize > {
825- Err ( vm. new_type_error ( "'str' object cannot be interpreted as an integer" . to_owned ( ) ) )
826- }
827- }
828-
829766impl DictKey for str {
830767 type Owned = String ;
831768 #[ inline]
@@ -964,7 +901,7 @@ mod tests {
964901 assert_eq ! ( true , dict. contains( & vm, & * key1) . unwrap( ) ) ;
965902 assert_eq ! ( true , dict. contains( & vm, "x" ) . unwrap( ) ) ;
966903
967- let val = dict. get ( & vm, & "x" ) . unwrap ( ) . unwrap ( ) ;
904+ let val = dict. get ( & vm, "x" ) . unwrap ( ) . unwrap ( ) ;
968905 vm. bool_eq ( & val, & value2)
969906 . expect ( "retrieved value must be equal to inserted value." ) ;
970907 } )
0 commit comments