]>
git.proxmox.com Git - rustc.git/blob - vendor/packed_simd_2/src/api/fmt/octal.rs
1 //! Implement Octal formatting
3 macro_rules
! impl_fmt_octal
{
4 ([$elem_ty
:ident
; $elem_count
:expr
]: $id
:ident
| $test_tt
:tt
) => {
5 impl crate::fmt
::Octal
for $id
{
6 #[allow(clippy::missing_inline_in_public_items)]
7 fn fmt(&self, f
: &mut crate::fmt
::Formatter
<'_
>) -> crate::fmt
::Result
{
8 write
!(f
, "{}(", stringify
!($id
))?
;
9 for i
in 0..$elem_count
{
13 self.extract(i
).fmt(f
)?
;
21 pub mod [<$id _fmt_octal
>] {
23 #[cfg_attr(not(target_arch = "wasm32"), test)]
24 #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
26 use arrayvec
::{ArrayString,ArrayVec}
;
27 type TinyString
= ArrayString
<[u8; 512]>;
29 use crate::fmt
::Write
;
30 let v
= $id
::splat($elem_ty
::default());
31 let mut s
= TinyString
::new();
32 write
!(&mut s
, "{:#o}", v
).unwrap();
34 let mut beg
= TinyString
::new();
35 write
!(&mut beg
, "{}(", stringify
!($id
)).unwrap();
36 assert
!(s
.starts_with(beg
.as_str()));
37 assert
!(s
.ends_with(")"));
38 let s
: ArrayVec
<[TinyString
; 64]>
39 = s
.replace(beg
.as_str(), "").replace(")", "")
41 .map(|v
| TinyString
::from(v
.trim()).unwrap())
43 assert_eq
!(s
.len(), $id
::lanes());
44 for (index
, ss
) in s
.into_iter().enumerate() {
45 let mut e
= TinyString
::new();
46 write
!(&mut e
, "{:#o}", v
.extract(index
)).unwrap();