pub(crate) fn virtual_node_for_key<K>(&self, key: &K) -> Result<&VirtualNode<N>>
    where
        K: Borrow<[u8]>,
    {
        // Return an error if the ring is empty...
        if self.vnodes.is_empty() {
            return Err(HashRingError::EmptyRing);
        }
        // ...otherwise find the correct index and return the associated vnode.
        let index = self
            .vnodes
            .binary_search_by(|vn| {
                let name: &[u8] = &vn.name;
                name.cmp(key.borrow())
            })
            .unwrap_or_else(|index| index)
            % self.vnodes.len();
        // SAFETY: The remainder of the above integer division is always a usize between `0` and
        //         `self.vnodes.len() - 1`, hence can be used as an index in `self.vnodes`.
        Ok(unsafe { self.vnodes.get_unchecked(index) })
    }
// returns a reference to the actual `VirtualNode` in `HashRingState.vnodes`
returns a reference to the actual `VirtualNode` in `HashRingState.vnodes`
returns a reference to the actual ` VirtualNode ` in ` HashRingState . vnodes `
pub(crate) fn virtual_node_for_key<K>(&self, key: &K) -> Result<&VirtualNode<N>>
    where
        K: Borrow<[u8]>,
    {
        // Return an error if the ring is empty...
        if self.vnodes.is_empty() {
            return Err(HashRingError::EmptyRing);
        }
        // ...otherwise find the correct index and return the associated vnode.
        let index = self
            .vnodes
            .binary_search_by(|vn| {
                let name: &[u8] = &vn.name;
                name.cmp(key.borrow())
            })
            .unwrap_or_else(|index| index)
            % self.vnodes.len();
        // SAFETY: The remainder of the above integer division is always a usize between `0` and
        //         `self.vnodes.len() - 1`, hence can be used as an index in `self.vnodes`.
        Ok(unsafe { self.vnodes.get_unchecked(index) })
    }
pub ( crate ) fn virtual_node_for_key < K > ( & self , key : & K ) -> Result < & VirtualNode < N > > where K : Borrow < [ u8 ] > , { // Return an error if the ring is empty... if self . vnodes . is_empty ( ) { return Err ( HashRingError :: EmptyRing ) ; } // ...otherwise find the correct index and return the associated vnode. let index = self . vnodes . binary_search_by ( | vn | { let name : & [ u8 ] = & vn . name ; name . cmp ( key . borrow ( ) ) } ) . unwrap_or_else ( | index | index ) % self . vnodes . len ( ) ; // SAFETY: The remainder of the above integer division is always a usize between `0` and //         `self.vnodes.len() - 1`, hence can be used as an index in `self.vnodes`. Ok ( unsafe { self . vnodes . get_unchecked ( index ) } ) }
returns a reference to the actual `VirtualNode` in `HashRingState.vnodes`
returns a reference to the actual ` VirtualNode ` in ` HashRingState . vnodes `
&self
key
&K
&self
key
&K