core/portable-simd/crates/core_simd/src/
fmt.rs

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