@@ -142,7 +142,6 @@ use reqwest_middleware::ClientBuilder as ReqwestMiddlewareClientBuilder;
142142use reqwest_retry:: RetryTransientMiddleware ;
143143pub use reqwest_retry:: policies:: ExponentialBackoff ;
144144
145- use debug_unsafe:: { option:: OptionUnwrapper , slice:: SliceGetter } ;
146145use serde:: { Serialize , de:: DeserializeOwned } ;
147146use std:: {
148147 future:: Future ,
@@ -257,7 +256,7 @@ impl Client {
257256 . with ( RetryTransientMiddleware :: new_with_policy ( retry_policy) )
258257 . build ( ) ;
259258
260- if url. len ( ) > 1 && url. chars ( ) . last ( ) . unwrap_safe_unchecked ( ) == '/' {
259+ if url. len ( ) > 1 && matches ! ( url. chars( ) . last( ) , Some ( '/' ) ) {
261260 url. pop ( ) ;
262261 }
263262
@@ -294,8 +293,10 @@ impl Client {
294293 /// Selects the next node to use for a request based on health and priority.
295294 fn get_next_node ( & self ) -> & Node {
296295 // if only one node (including nearest)
297- if self . nodes . len ( ) == 1 {
298- return self . nodes . first ( ) . unwrap_safe_unchecked ( ) ;
296+ if self . nodes . len ( ) == 1
297+ && let Some ( first) = self . nodes . first ( )
298+ {
299+ return first;
299300 }
300301
301302 let ( nodes_len, mut index) = if self . is_nearest_node_set {
@@ -309,7 +310,7 @@ impl Client {
309310 } ;
310311
311312 for _ in 0 ..self . nodes . len ( ) {
312- let node = self . nodes . get_safe_unchecked ( index) ;
313+ let node = & self . nodes [ index] ;
313314
314315 if node. is_healthy . load ( Ordering :: Relaxed )
315316 || node. last_accessed . read ( ) . unwrap ( ) . elapsed ( ) >= self . healthcheck_interval
@@ -322,7 +323,7 @@ impl Client {
322323 // If all nodes are unhealthy and not due for a check, just pick the next one in the round-robin.
323324 // This gives it a chance to prove it has recovered.
324325 index = self . current_node_index . load ( Ordering :: Relaxed ) % self . nodes . len ( ) ;
325- self . nodes . get_safe_unchecked ( index)
326+ & self . nodes [ index]
326327 }
327328
328329 /// For use in legacy APIs.
0 commit comments