]> git.proxmox.com Git - rustc.git/blame - vendor/packed_simd/src/api/cmp/ord.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / vendor / packed_simd / src / api / cmp / ord.rs
CommitLineData
f20569fa
XL
1//! Implements `Ord` for vector types.
2
3macro_rules! impl_cmp_ord {
4 (
5 [$elem_ty:ident; $elem_count:expr]:
6 $id:ident | $test_tt:tt |
7 ($true:expr, $false:expr)
8 ) => {
9 impl $id {
10 /// Returns a wrapper that implements `Ord`.
11 #[inline]
12 pub fn lex_ord(&self) -> LexicographicallyOrdered<$id> {
13 LexicographicallyOrdered(*self)
14 }
15 }
16
17 impl crate::cmp::Ord for LexicographicallyOrdered<$id> {
18 #[inline]
19 fn cmp(&self, other: &Self) -> crate::cmp::Ordering {
20 match self.partial_cmp(other) {
21 Some(x) => x,
22 None => unsafe { crate::hint::unreachable_unchecked() },
23 }
24 }
25 }
26
27 test_if!{
28 $test_tt:
29 paste::item! {
30 pub mod [<$id _cmp_ord>] {
31 use super::*;
32 #[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
33 fn eq() {
34 fn foo<E: crate::cmp::Ord>(_: E) {}
35 let a = $id::splat($false);
36 foo(a.partial_lex_ord());
37 foo(a.lex_ord());
38 }
39 }
40 }
41 }
42 };
43}