@@ -915,23 +915,10 @@ impl<T, A: Allocator + Clone> RawTable<T, A> {
915
915
/// Searches for an element in the table,
916
916
/// or a potential slot where that element could be inserted.
917
917
#[ inline]
918
- pub fn find_potential (
919
- & self ,
920
- hash : u64 ,
921
- mut eq : impl FnMut ( & T ) -> bool ,
922
- ) -> Result < Bucket < T > , usize > {
923
- unsafe {
924
- let result = self . table . find_potential_inner ( hash, & mut |index| {
925
- let bucket = self . bucket ( index) ;
926
- let elm = bucket. as_ref ( ) ;
927
- eq ( elm)
928
- } ) ;
929
-
930
- match result {
931
- Ok ( index) => Ok ( self . bucket ( index) ) ,
932
- Err ( index) => Err ( index) ,
933
- }
934
- }
918
+ pub fn find_potential ( & self , hash : u64 , mut eq : impl FnMut ( & T ) -> bool ) -> ( usize , bool ) {
919
+ self . table . find_potential_inner ( hash, & mut |index| unsafe {
920
+ eq ( self . bucket ( index) . as_ref ( ) )
921
+ } )
935
922
}
936
923
937
924
/// Inserts an element in the table at a potential slot as returned by `find_potential`.
@@ -1224,12 +1211,12 @@ impl<A: Allocator + Clone> RawTableInner<A> {
1224
1211
/// Searches for an element in the table, stopping at the group where `stop` returns `Some` and
1225
1212
/// no elements matched. Returns the bucket that matches or the result of `stop`.
1226
1213
#[ inline]
1227
- unsafe fn search < R > (
1214
+ unsafe fn search (
1228
1215
& self ,
1229
1216
hash : u64 ,
1230
1217
eq : & mut dyn FnMut ( usize ) -> bool ,
1231
- mut stop : impl FnMut ( & Group , & ProbeSeq ) -> Option < R > ,
1232
- ) -> Result < usize , R > {
1218
+ mut stop : impl FnMut ( & Group , & ProbeSeq ) -> Option < usize > ,
1219
+ ) -> ( usize , bool ) {
1233
1220
let h2_hash = h2 ( hash) ;
1234
1221
let mut probe_seq = self . probe_seq ( hash) ;
1235
1222
@@ -1240,12 +1227,12 @@ impl<A: Allocator + Clone> RawTableInner<A> {
1240
1227
let index = ( probe_seq. pos + bit) & self . bucket_mask ;
1241
1228
1242
1229
if likely ( eq ( index) ) {
1243
- return Ok ( index) ;
1230
+ return ( index, true ) ;
1244
1231
}
1245
1232
}
1246
1233
1247
1234
if let Some ( stop) = stop ( & group, & probe_seq) {
1248
- return Err ( stop) ;
1235
+ return ( stop, false ) ;
1249
1236
}
1250
1237
1251
1238
probe_seq. move_next ( self . bucket_mask ) ;
@@ -1295,7 +1282,7 @@ impl<A: Allocator + Clone> RawTableInner<A> {
1295
1282
& self ,
1296
1283
hash : u64 ,
1297
1284
eq : & mut dyn FnMut ( usize ) -> bool ,
1298
- ) -> Result < usize , usize > {
1285
+ ) -> ( usize , bool ) {
1299
1286
unsafe {
1300
1287
let mut tombstone = None ;
1301
1288
self . search ( hash, eq, |group, probe_seq| {
0 commit comments