core_simd/fmt.rs
1use crate::simd::{Simd, SimdElement};
2use core::fmt;
3
4impl<T, const N: usize> fmt::Debug for Simd<T, N>
5where
6 T: SimdElement + fmt::Debug,
7{
8 /// A `Simd<T, N>` has a debug format like the one for `[T]`:
9 /// ```
10 /// # #![feature(portable_simd)]
11 /// # #[cfg(feature = "as_crate")] use core_simd::simd::Simd;
12 /// # #[cfg(not(feature = "as_crate"))] use core::simd::Simd;
13 /// let floats = Simd::<f32, 4>::splat(-1.0);
14 /// assert_eq!(format!("{:?}", [-1.0; 4]), format!("{:?}", floats));
15 /// ```
16 #[inline]
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 <[T] as fmt::Debug>::fmt(self.as_array(), f)
19 }
20}