Struct unordered_pair::UnorderedPair
source · [−]pub struct UnorderedPair<T>(pub T, pub T);
Expand description
A tuple struct representing an unordered pair
Tuple Fields
0: T
1: T
Implementations
sourceimpl<T: Ord> UnorderedPair<T>
impl<T: Ord> UnorderedPair<T>
sourcepub fn into_ordered_tuple(self) -> (T, T)
pub fn into_ordered_tuple(self) -> (T, T)
Transforms the UnorderedPair<T>
into a (T,T)
.
The tuple’s components are always in the same order, smallest to largest.
Examples
use unordered_pair::UnorderedPair;
let pair = UnorderedPair(1,2);
let rev = UnorderedPair(2,1);
let tuple_pair = pair.into_ordered_tuple();
let tuple_rev = rev.into_ordered_tuple();
assert_eq!(tuple_pair, (1,2));
assert_eq!(tuple_rev, (1,2));
Trait Implementations
sourceimpl<T: Clone> Clone for UnorderedPair<T>
impl<T: Clone> Clone for UnorderedPair<T>
sourcefn clone(&self) -> UnorderedPair<T>
fn clone(&self) -> UnorderedPair<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for UnorderedPair<T>
impl<T: Debug> Debug for UnorderedPair<T>
sourceimpl<T: Default> Default for UnorderedPair<T>
impl<T: Default> Default for UnorderedPair<T>
sourcefn default() -> UnorderedPair<T>
fn default() -> UnorderedPair<T>
Returns the “default value” for a type. Read more
sourceimpl<'de, T> Deserialize<'de> for UnorderedPair<T> where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for UnorderedPair<T> where
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T> From<(T, T)> for UnorderedPair<T>
impl<T> From<(T, T)> for UnorderedPair<T>
sourcefn from(tuple: (T, T)) -> UnorderedPair<T>
fn from(tuple: (T, T)) -> UnorderedPair<T>
Converts to this type from the input type.
sourceimpl<T> From<UnorderedPair<T>> for (T, T)
impl<T> From<UnorderedPair<T>> for (T, T)
sourcefn from(pair: UnorderedPair<T>) -> (T, T)
fn from(pair: UnorderedPair<T>) -> (T, T)
Converts to this type from the input type.
sourceimpl<T> Hash for UnorderedPair<T> where
T: Ord + Hash,
impl<T> Hash for UnorderedPair<T> where
T: Ord + Hash,
Computes the same hash regardless of the order of the contained items
sourceimpl<T> PartialEq<UnorderedPair<T>> for UnorderedPair<T> where
T: PartialEq,
impl<T> PartialEq<UnorderedPair<T>> for UnorderedPair<T> where
T: PartialEq,
Compares two pairs while disregarding the order of the contained items
sourceimpl<T> Serialize for UnorderedPair<T> where
T: Serialize,
impl<T> Serialize for UnorderedPair<T> where
T: Serialize,
impl<T: Copy> Copy for UnorderedPair<T>
impl<T: Eq> Eq for UnorderedPair<T>
impl<T> StructuralEq for UnorderedPair<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for UnorderedPair<T> where
T: RefUnwindSafe,
impl<T> Send for UnorderedPair<T> where
T: Send,
impl<T> Sync for UnorderedPair<T> where
T: Sync,
impl<T> Unpin for UnorderedPair<T> where
T: Unpin,
impl<T> UnwindSafe for UnorderedPair<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more