]>
git.proxmox.com Git - rustc.git/blob - vendor/packed_simd_2/src/api/fmt/debug.rs
1 //! Implement debug formatting
3 macro_rules
! impl_fmt_debug_tests
{
4 ([$elem_ty
:ty
; $elem_count
:expr
]: $id
:ident
| $test_tt
:tt
) => {
8 pub mod [<$id _fmt_debug
>] {
10 #[cfg_attr(not(target_arch = "wasm32"), test)]
11 #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
13 use arrayvec
::{ArrayString,ArrayVec}
;
14 type TinyString
= ArrayString
<[u8; 512]>;
16 use crate::fmt
::Write
;
17 let v
= $id
::default();
18 let mut s
= TinyString
::new();
19 write
!(&mut s
, "{:?}", v
).unwrap();
21 let mut beg
= TinyString
::new();
22 write
!(&mut beg
, "{}(", stringify
!($id
)).unwrap();
23 assert
!(s
.starts_with(beg
.as_str()));
24 assert
!(s
.ends_with(")"));
25 let s
: ArrayVec
<[TinyString
; 64]>
26 = s
.replace(beg
.as_str(), "")
27 .replace(")", "").split(",")
28 .map(|v
| TinyString
::from(v
.trim()).unwrap())
30 assert_eq
!(s
.len(), $id
::lanes());
31 for (index
, ss
) in s
.into_iter().enumerate() {
32 let mut e
= TinyString
::new();
33 write
!(&mut e
, "{:?}", v
.extract(index
)).unwrap();
43 macro_rules
! impl_fmt_debug
{
44 ([$elem_ty
:ty
; $elem_count
:expr
]: $id
:ident
| $test_tt
:tt
) => {
45 impl crate::fmt
::Debug
for $id
{
46 #[allow(clippy::missing_inline_in_public_items)]
47 fn fmt(&self, f
: &mut crate::fmt
::Formatter
<'_
>) -> crate::fmt
::Result
{
48 write
!(f
, "{}(", stringify
!($id
))?
;
49 for i
in 0..$elem_count
{
53 self.extract(i
).fmt(f
)?
;
58 impl_fmt_debug_tests
!([$elem_ty
; $elem_count
]: $id
| $test_tt
);