pub struct UOrd<T, const N: usize> { /* private fields */ }Expand description
An unordered tuple of items of type T and length N.
UOrd is implemented such that the order of elements on creation does not matter,
and the UOrds created from different ordered lists will behave similarly in
PartialEq, Ord, or Hash.
UOrd’s implementation maintains a sorted list of values that is not allowed
to be mutated. Using interior mutability to mutate elements of a UOrd is a logic error
and is not supported. Doing so is very likely to cause strange behavior.
Implementations§
Source§impl<T, const N: usize> UOrd<T, N>where
T: Ord,
impl<T, const N: usize> UOrd<T, N>where
T: Ord,
Sourcepub fn replace<Q>(&self, from: &Q, to: &T) -> Self
pub fn replace<Q>(&self, from: &Q, to: &T) -> Self
Replaces any occurrence of from with to, creating a new UOrd.
Sourcepub fn try_map_opt<U>(self, f: impl FnMut(T) -> Option<U>) -> Option<UOrd<U, N>>where
U: Ord,
Available on crate feature alloc only.
pub fn try_map_opt<U>(self, f: impl FnMut(T) -> Option<U>) -> Option<UOrd<U, N>>where
U: Ord,
alloc only.Applies a fallible function f to each element of this UOrd, returning a value of type Option<UOrd<U, N>>.
The provided function takes a T and must return a value of type Option<U>.
This function is temporary, and will be deprecated when try_trait_v2 is stabilized.
Sourcepub fn try_map_res<U, E>(
self,
f: impl FnMut(T) -> Result<U, E>,
) -> Result<UOrd<U, N>, E>where
U: Ord,
Available on crate feature alloc only.
pub fn try_map_res<U, E>(
self,
f: impl FnMut(T) -> Result<U, E>,
) -> Result<UOrd<U, N>, E>where
U: Ord,
alloc only.Applies a fallible function f to each element of this UOrd, returning a value of type Result<UOrd<U, N>, E>.
The provided function takes a T and must return a value of type Return<U, E>.
This function is temporary, and will be deprecated when try_trait_v2 is stabilized.
Sourcepub fn convert<U>(self) -> UOrd<U, N>
pub fn convert<U>(self) -> UOrd<U, N>
Converts each element of this UOrd into a given type U
based on T’s Into<U> implementation.
Sourcepub fn try_convert<U>(self) -> Result<UOrd<U, N>, T::Error>
Available on crate feature alloc only.
pub fn try_convert<U>(self) -> Result<UOrd<U, N>, T::Error>
alloc only.Fallibly converts each element of this UOrd into a given type U
based on T’s TryInto<U> implementation, alternatively returning error.
Sourcepub fn test_all(&self, f: impl FnMut(&T) -> bool) -> bool
pub fn test_all(&self, f: impl FnMut(&T) -> bool) -> bool
Tests if all elements pass the given predicate.
Equivalent to self.iter().all(f).
Sourcepub fn test_any(&self, f: impl FnMut(&T) -> bool) -> bool
pub fn test_any(&self, f: impl FnMut(&T) -> bool) -> bool
Tests if any element passes the given predicate.
Equivalent to self.iter().any(f).
Sourcepub fn make_proxied<P: Proxy<T>>(self) -> UOrdProxied<T, N, P>
pub fn make_proxied<P: Proxy<T>>(self) -> UOrdProxied<T, N, P>
Converts this UOrd into a UOrdProxied by wrapping its contained elements of type T
in ProxyWrappers, using the provided Proxy P for comparison and equality.
Source§impl<T, const N: usize> UOrd<T, N>
impl<T, const N: usize> UOrd<T, N>
Sourcepub fn as_ref_array(&self) -> [&T; N]
pub fn as_ref_array(&self) -> [&T; N]
Borrows each element in this UOrd, returning an array of those references.
Sourcepub const fn as_array(&self) -> &[T; N]
pub const fn as_array(&self) -> &[T; N]
Returns an immutable reference to the array of elements, which is sorted.
Sourcepub const fn into_array(self) -> [T; N]
pub const fn into_array(self) -> [T; N]
Converts this UOrd into its array of elements, which is sorted.
Sourcepub fn into_tuple(self) -> <[T; N] as IntoTuple>::Tuplewhere
[T; N]: IntoTuple,
pub fn into_tuple(self) -> <[T; N] as IntoTuple>::Tuplewhere
[T; N]: IntoTuple,
Converts this UOrd into a tuple of length N similarly to into_array.
Source§impl<T, const N: usize, P> UOrd<ProxyWrapper<T, P>, N>where
P: Proxy<T>,
impl<T, const N: usize, P> UOrd<ProxyWrapper<T, P>, N>where
P: Proxy<T>,
Sourcepub fn new_proxied(values: [T; N]) -> Self
pub fn new_proxied(values: [T; N]) -> Self
Create a new UOrdProxied from an array of values, utilizing a custom Proxy for comparison and equality.
Sourcepub fn contains_proxied<Q>(&self, x: &Q) -> bool
pub fn contains_proxied<Q>(&self, x: &Q) -> bool
Tests whether this UOrdProxied contains the given value.
Sourcepub fn replace_proxied<Q>(&self, from: &Q, to: &T) -> Self
pub fn replace_proxied<Q>(&self, from: &Q, to: &T) -> Self
Replaces any occurrence of from with to, creating a new UOrdProxied.
Sourcepub const fn min_proxied(&self) -> &T
pub const fn min_proxied(&self) -> &T
Gets the first (smallest) element in the internal list, stripped of its wrappers.
§Panics
This function will panic if N == 0.
Sourcepub const fn max_proxied(&self) -> &T
pub const fn max_proxied(&self) -> &T
Gets the last (greatest) element in the internal list, stripped of its wrappers.
§Panics
This function will panic if N == 0.
Sourcepub fn each_ref_proxied(&self) -> UOrd<&T, N>where
T: Ord,
pub fn each_ref_proxied(&self) -> UOrd<&T, N>where
T: Ord,
Borrows each element in this UOrdProxied, returning a UOrd of those references, stripped of their wrappers.
Sourcepub fn as_ref_array_proxied(&self) -> [&T; N]
pub fn as_ref_array_proxied(&self) -> [&T; N]
Borrows each element in this UOrdProxied, returning an array of those references, stripped of their wrappers.
Sourcepub const fn as_array_proxied(&self) -> &[T; N]
pub const fn as_array_proxied(&self) -> &[T; N]
Returns an immutable reference to the array of elements, which is sorted, and has each element stripped of their wrappers.
Sourcepub const fn into_array_proxied(self) -> [T; N]
pub const fn into_array_proxied(self) -> [T; N]
Converts this UOrdProxied into its array of elements, which is sorted, and has each element stripped of their wrappers.
Sourcepub fn into_tuple_proxied(self) -> <[T; N] as IntoTuple>::Tuplewhere
[T; N]: IntoTuple,
pub fn into_tuple_proxied(self) -> <[T; N] as IntoTuple>::Tuplewhere
[T; N]: IntoTuple,
Converts this UOrd into a tuple of length N similarly to into_array, and has each element stripped of their wrappers..
Sourcepub fn map_proxied<U, R>(self, f: impl FnMut(T) -> U) -> UOrdProxied<U, N, R>where
R: Proxy<U>,
pub fn map_proxied<U, R>(self, f: impl FnMut(T) -> U) -> UOrdProxied<U, N, R>where
R: Proxy<U>,
Applies the function f to each element of this UOrdProxied, returning a new UOrdProxied.
This function also allows a proxy, R, for the new UOrdProxied to be specified.
Sourcepub fn map_each_ref_proxied<U, R>(
&self,
f: impl FnMut(&T) -> U,
) -> UOrdProxied<U, N, R>where
R: Proxy<U>,
pub fn map_each_ref_proxied<U, R>(
&self,
f: impl FnMut(&T) -> U,
) -> UOrdProxied<U, N, R>where
R: Proxy<U>,
Applies the function f to a reference to each element of this UOrdProxied, returning a new UOrdProxied.
This function also allows a proxy, R, for the new UOrdProxied to be specified.
Sourcepub fn try_map_proxied_opt<U, R>(
self,
f: impl FnMut(T) -> Option<U>,
) -> Option<UOrdProxied<U, N, R>>where
R: Proxy<U>,
Available on crate feature alloc only.
pub fn try_map_proxied_opt<U, R>(
self,
f: impl FnMut(T) -> Option<U>,
) -> Option<UOrdProxied<U, N, R>>where
R: Proxy<U>,
alloc only.Applies a fallible function f to each element of this UOrdProxied, returning a value of type Option<UOrdProxied<U, N, R>>.
The provided function takes a T and must return a value of type Option<U>.
This function also allows a proxy, R, for the new UOrdProxied to be specified.
This function is temporary, and will be deprecated when try_trait_v2 is stabilized.
Sourcepub fn try_map_proxied_res<U, R, E>(
self,
f: impl FnMut(T) -> Result<U, E>,
) -> Result<UOrdProxied<U, N, R>, E>where
R: Proxy<U>,
Available on crate feature alloc only.
pub fn try_map_proxied_res<U, R, E>(
self,
f: impl FnMut(T) -> Result<U, E>,
) -> Result<UOrdProxied<U, N, R>, E>where
R: Proxy<U>,
alloc only.Applies a fallible function f to each element of this UOrdProxied, returning a value of type Result<UOrdProxied<U, N, R>, E>.
The provided function takes a T and must return a value of type Return<U, E>.
This function also allows a proxy, R, for the new UOrdProxied to be specified.
This function is temporary, and will be deprecated when try_trait_v2 is stabilized.
Sourcepub fn convert_proxied<U, R>(self) -> UOrdProxied<U, N, R>
pub fn convert_proxied<U, R>(self) -> UOrdProxied<U, N, R>
Converts each element of this UOrdProxied into a given type U
based on T’s Into<U> implementation.
Sourcepub fn try_convert_proxied<U, R>(self) -> Result<UOrdProxied<U, N, R>, T::Error>
Available on crate feature alloc only.
pub fn try_convert_proxied<U, R>(self) -> Result<UOrdProxied<U, N, R>, T::Error>
alloc only.Fallibly converts each element of this UOrdProxied into a given type U
based on T’s TryInto<U> implementation, alternatively returning error.
Sourcepub fn test_all_proxied(&self, f: impl FnMut(&T) -> bool) -> bool
pub fn test_all_proxied(&self, f: impl FnMut(&T) -> bool) -> bool
Tests if all elements pass the given predicate.
Equivalent to self.iter_proxied().all(f).
Sourcepub fn test_any_proxied(&self, f: impl FnMut(&T) -> bool) -> bool
pub fn test_any_proxied(&self, f: impl FnMut(&T) -> bool) -> bool
Tests if any element passes the given predicate.
Equivalent to self.iter_proxied().any(f).
Sourcepub fn make_unproxied(self) -> UOrd<T, N>where
T: Ord,
pub fn make_unproxied(self) -> UOrd<T, N>where
T: Ord,
Converts this UOrdProxied into a UOrd, unwrapping the contained
ProxyWrappers, using the default implementation of Ord on T for comparison and equality.
Sourcepub fn iter_proxied(&self) -> UOrdProxiedIter<'_, T, N, P> ⓘ
pub fn iter_proxied(&self) -> UOrdProxiedIter<'_, T, N, P> ⓘ
Creates an iterator over references to each element of this UOrdProxied, stripped of their wrappers.
Sourcepub fn into_iter_proxied(self) -> UOrdProxiedIntoIter<T, N, P> ⓘ
pub fn into_iter_proxied(self) -> UOrdProxiedIntoIter<T, N, P> ⓘ
Creates an iterator over each element of this UOrdProxied, stripped of their wrappers.
Source§impl<T> UOrd<T, 2>where
T: Ord,
impl<T> UOrd<T, 2>where
T: Ord,
Sourcepub fn is_distinct(&self) -> bool
pub fn is_distinct(&self) -> bool
Returns true if this pair was distinct (the values in it were not equal to each other) otherwise returns false.
Sourcepub fn other<Q>(&self, x: &Q) -> Option<&T>
pub fn other<Q>(&self, x: &Q) -> Option<&T>
If this unordered pair contains the given value, this function will return the other value.
If this unordered pair did not contain the given value, this will return None.
Note that this function does not care about the distinctness of the pair, and will
still return the other value, even if it was equal to the input value.
If you need this behavior, see UOrd::other_distinct.
Sourcepub fn other_distinct<Q>(&self, x: &Q) -> Option<&T>
pub fn other_distinct<Q>(&self, x: &Q) -> Option<&T>
If this unordered pair contains the given value, this function will return the other value.
If this unordered pair did not contain the given value, this will return None.
Additionally, this function will return None if the two items in this pair were equal,
guaranteeing that the output value is never equal to the input value in the case of an indistinct pair.
Source§impl<T, P> UOrd<ProxyWrapper<T, P>, 2>where
P: Proxy<T>,
impl<T, P> UOrd<ProxyWrapper<T, P>, 2>where
P: Proxy<T>,
Sourcepub fn other_proxied<Q>(&self, x: &Q) -> Option<&T>
pub fn other_proxied<Q>(&self, x: &Q) -> Option<&T>
If this unordered pair contains the given value, this function will return the other value.
If this unordered pair did not contain the given value, this will return None.
Note that this function does not care about the distinctness of the pair, and will
still return the other value, even if it was equal to the input value.
If you need this behavior, see UOrdProxied::other_distinct_proxied.
Sourcepub fn other_distinct_proxied<Q>(&self, x: &Q) -> Option<&T>
pub fn other_distinct_proxied<Q>(&self, x: &Q) -> Option<&T>
If this unordered pair contains the given value, this function will return the other value.
If this unordered pair did not contain the given value, this will return None.
Additionally, this function will return None if the two items in this pair were equal,
guaranteeing that the output value is never equal to the input value in the case of an indistinct pair.
Trait Implementations§
Source§impl<'de, T, const N: usize> Deserialize<'de> for UOrd<T, N>where
T: Deserialize<'de> + Ord,
Available on crate feature serde only.
impl<'de, T, const N: usize> Deserialize<'de> for UOrd<T, N>where
T: Deserialize<'de> + Ord,
serde only.Source§fn 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>,
Source§impl<T> From<(T, T, T, T)> for UOrd<T, 4>where
T: Ord,
impl<T> From<(T, T, T, T)> for UOrd<T, 4>where
T: Ord,
Source§fn from(value: (T, T, T, T)) -> UOrd<T, 4>
fn from(value: (T, T, T, T)) -> UOrd<T, 4>
Source§impl<T> From<(T, T, T, T, T)> for UOrd<T, 5>where
T: Ord,
impl<T> From<(T, T, T, T, T)> for UOrd<T, 5>where
T: Ord,
Source§fn from(value: (T, T, T, T, T)) -> UOrd<T, 5>
fn from(value: (T, T, T, T, T)) -> UOrd<T, 5>
Source§impl<T> From<(T, T, T, T, T, T)> for UOrd<T, 6>where
T: Ord,
impl<T> From<(T, T, T, T, T, T)> for UOrd<T, 6>where
T: Ord,
Source§fn from(value: (T, T, T, T, T, T)) -> UOrd<T, 6>
fn from(value: (T, T, T, T, T, T)) -> UOrd<T, 6>
Source§impl<T> From<(T, T, T, T, T, T, T)> for UOrd<T, 7>where
T: Ord,
impl<T> From<(T, T, T, T, T, T, T)> for UOrd<T, 7>where
T: Ord,
Source§fn from(value: (T, T, T, T, T, T, T)) -> UOrd<T, 7>
fn from(value: (T, T, T, T, T, T, T)) -> UOrd<T, 7>
Source§impl<T> From<(T, T, T, T, T, T, T, T)> for UOrd<T, 8>where
T: Ord,
impl<T> From<(T, T, T, T, T, T, T, T)> for UOrd<T, 8>where
T: Ord,
Source§fn from(value: (T, T, T, T, T, T, T, T)) -> UOrd<T, 8>
fn from(value: (T, T, T, T, T, T, T, T)) -> UOrd<T, 8>
Source§impl<T> From<(T, T, T, T, T, T, T, T, T)> for UOrd<T, 9>where
T: Ord,
impl<T> From<(T, T, T, T, T, T, T, T, T)> for UOrd<T, 9>where
T: Ord,
Source§fn from(value: (T, T, T, T, T, T, T, T, T)) -> UOrd<T, 9>
fn from(value: (T, T, T, T, T, T, T, T, T)) -> UOrd<T, 9>
Source§impl<T> From<(T, T, T, T, T, T, T, T, T, T)> for UOrd<T, 10>where
T: Ord,
impl<T> From<(T, T, T, T, T, T, T, T, T, T)> for UOrd<T, 10>where
T: Ord,
Source§fn from(value: (T, T, T, T, T, T, T, T, T, T)) -> UOrd<T, 10>
fn from(value: (T, T, T, T, T, T, T, T, T, T)) -> UOrd<T, 10>
Source§impl<T> From<(T, T, T, T, T, T, T, T, T, T, T)> for UOrd<T, 11>where
T: Ord,
impl<T> From<(T, T, T, T, T, T, T, T, T, T, T)> for UOrd<T, 11>where
T: Ord,
Source§fn from(value: (T, T, T, T, T, T, T, T, T, T, T)) -> UOrd<T, 11>
fn from(value: (T, T, T, T, T, T, T, T, T, T, T)) -> UOrd<T, 11>
Source§impl<T> From<(T, T, T, T, T, T, T, T, T, T, T, T)> for UOrd<T, 12>where
T: Ord,
impl<T> From<(T, T, T, T, T, T, T, T, T, T, T, T)> for UOrd<T, 12>where
T: Ord,
Source§fn from(value: (T, T, T, T, T, T, T, T, T, T, T, T)) -> UOrd<T, 12>
fn from(value: (T, T, T, T, T, T, T, T, T, T, T, T)) -> UOrd<T, 12>
Source§impl<T> From<UOrd<T, 10>> for (T, T, T, T, T, T, T, T, T, T)
impl<T> From<UOrd<T, 10>> for (T, T, T, T, T, T, T, T, T, T)
Source§fn from(value: UOrd<T, 10>) -> (T, T, T, T, T, T, T, T, T, T)
fn from(value: UOrd<T, 10>) -> (T, T, T, T, T, T, T, T, T, T)
Source§impl<T> From<UOrd<T, 11>> for (T, T, T, T, T, T, T, T, T, T, T)
impl<T> From<UOrd<T, 11>> for (T, T, T, T, T, T, T, T, T, T, T)
Source§fn from(value: UOrd<T, 11>) -> (T, T, T, T, T, T, T, T, T, T, T)
fn from(value: UOrd<T, 11>) -> (T, T, T, T, T, T, T, T, T, T, T)
Source§impl<T> From<UOrd<T, 12>> for (T, T, T, T, T, T, T, T, T, T, T, T)
impl<T> From<UOrd<T, 12>> for (T, T, T, T, T, T, T, T, T, T, T, T)
Source§fn from(value: UOrd<T, 12>) -> (T, T, T, T, T, T, T, T, T, T, T, T)
fn from(value: UOrd<T, 12>) -> (T, T, T, T, T, T, T, T, T, T, T, T)
Source§impl<T> From<UOrd<T, 4>> for (T, T, T, T)
impl<T> From<UOrd<T, 4>> for (T, T, T, T)
Source§fn from(value: UOrd<T, 4>) -> (T, T, T, T)
fn from(value: UOrd<T, 4>) -> (T, T, T, T)
Source§impl<T> From<UOrd<T, 5>> for (T, T, T, T, T)
impl<T> From<UOrd<T, 5>> for (T, T, T, T, T)
Source§fn from(value: UOrd<T, 5>) -> (T, T, T, T, T)
fn from(value: UOrd<T, 5>) -> (T, T, T, T, T)
Source§impl<T> From<UOrd<T, 6>> for (T, T, T, T, T, T)
impl<T> From<UOrd<T, 6>> for (T, T, T, T, T, T)
Source§fn from(value: UOrd<T, 6>) -> (T, T, T, T, T, T)
fn from(value: UOrd<T, 6>) -> (T, T, T, T, T, T)
Source§impl<T> From<UOrd<T, 7>> for (T, T, T, T, T, T, T)
impl<T> From<UOrd<T, 7>> for (T, T, T, T, T, T, T)
Source§fn from(value: UOrd<T, 7>) -> (T, T, T, T, T, T, T)
fn from(value: UOrd<T, 7>) -> (T, T, T, T, T, T, T)
Source§impl<T> From<UOrd<T, 8>> for (T, T, T, T, T, T, T, T)
impl<T> From<UOrd<T, 8>> for (T, T, T, T, T, T, T, T)
Source§fn from(value: UOrd<T, 8>) -> (T, T, T, T, T, T, T, T)
fn from(value: UOrd<T, 8>) -> (T, T, T, T, T, T, T, T)
Source§impl<T> From<UOrd<T, 9>> for (T, T, T, T, T, T, T, T, T)
impl<T> From<UOrd<T, 9>> for (T, T, T, T, T, T, T, T, T)
Source§fn from(value: UOrd<T, 9>) -> (T, T, T, T, T, T, T, T, T)
fn from(value: UOrd<T, 9>) -> (T, T, T, T, T, T, T, T, T)
Source§impl<'a, T, const N: usize> IntoIterator for &'a UOrd<T, N>
impl<'a, T, const N: usize> IntoIterator for &'a UOrd<T, N>
Source§impl<T, const N: usize> IntoIterator for UOrd<T, N>
impl<T, const N: usize> IntoIterator for UOrd<T, N>
Source§impl<T, const N: usize> Ord for UOrd<T, N>where
T: Ord,
impl<T, const N: usize> Ord for UOrd<T, N>where
T: Ord,
Source§impl<T, const N: usize> PartialOrd for UOrd<T, N>where
T: Ord,
impl<T, const N: usize> PartialOrd for UOrd<T, N>where
T: Ord,
Source§impl<T, const N: usize> Serialize for UOrd<T, N>where
T: Serialize,
Available on crate feature serde only.
impl<T, const N: usize> Serialize for UOrd<T, N>where
T: Serialize,
serde only.