use core::borrow::Borrow;
use core::ops::Index;
use super::OSBTreeSet;
use crate::Rank;
impl<T: Clone + Ord> OSBTreeSet<T> {
#[must_use]
pub fn get_by_rank(&self, rank: usize) -> Option<&T> {
self.map.get_by_rank(rank).map(|(k, ())| k)
}
#[must_use]
pub fn rank_of<Q>(&self, value: &Q) -> Option<usize>
where
T: Borrow<Q>,
Q: ?Sized + Ord,
{
self.map.rank_of(value)
}
}
impl<T: Clone + Ord> Index<Rank> for OSBTreeSet<T> {
type Output = T;
fn index(&self, rank: Rank) -> &Self::Output {
self.get_by_rank(rank.0).expect("index out of bounds")
}
}