A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.rs/equivalent/1.0.2/src/equivalent/lib.rs.html below:

lib.rs - source

1#![no_std]
63
64use core::borrow::Borrow;
65use core::cmp::Ordering;
66
67pub trait Equivalent<K: ?Sized> {
78    fn equivalent(&self, key: &K) -> bool;
80}
81
82impl<Q: ?Sized, K: ?Sized> Equivalent<K> for Q
83where
84    Q: Eq,
85    K: Borrow<Q>,
86{
87    #[inline]
88    fn equivalent(&self, key: &K) -> bool {
89        PartialEq::eq(self, key.borrow())
90    }
91}
92
93pub trait Comparable<K: ?Sized>: Equivalent<K> {
100    fn compare(&self, key: &K) -> Ordering;
102}
103
104impl<Q: ?Sized, K: ?Sized> Comparable<K> for Q
105where
106    Q: Ord,
107    K: Borrow<Q>,
108{
109    #[inline]
110    fn compare(&self, key: &K) -> Ordering {
111        Ord::cmp(self, key.borrow())
112    }
113}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4