1use std::alloc::Layout;
2
3use crate::{Field, FieldFlags, Innards, Shape, ShapeDesc, Shapely, mini_typeid};
4
5impl<T0> Shapely for (T0,)
6where
7 T0: Shapely,
8{
9 fn shape() -> Shape {
10 macro_rules! field {
11 ($idx:tt, $ty:ty) => {
12 Field {
13 name: stringify!($idx),
14 shape: ShapeDesc(<$ty>::shape),
15 offset: std::mem::offset_of!((T0,), $idx),
16 flags: FieldFlags::EMPTY,
17 }
18 };
19 }
20
21 Shape {
22 name: |f, opts| {
23 if let Some(opts) = opts.for_children() {
24 write!(f, "(")?;
25 (T0::shape().name)(f, opts)?;
26 write!(f, ")")
27 } else {
28 write!(f, "()")
29 }
30 },
31 typeid: mini_typeid::of::<Self>(),
32 layout: Layout::new::<(T0,)>(),
33 innards: Innards::Tuple {
34 fields: &const { [field!(0, T0)] },
35 },
36 set_to_default: None,
37 drop_in_place: Some(|addr: *mut u8| unsafe {
38 std::ptr::drop_in_place(addr as *mut (T0,));
39 }),
40 }
41 }
42}
43
44impl<T0, T1> Shapely for (T0, T1)
45where
46 T0: Shapely,
47 T1: Shapely,
48{
49 fn shape() -> Shape {
50 macro_rules! field {
51 ($idx:tt, $ty:ty) => {
52 Field {
53 name: stringify!($idx),
54 shape: ShapeDesc(<$ty>::shape),
55 offset: std::mem::offset_of!((T0, T1), $idx),
56 flags: FieldFlags::EMPTY,
57 }
58 };
59 }
60
61 Shape {
62 name: |f, opts| {
63 if let Some(opts) = opts.for_children() {
64 write!(f, "(")?;
65 (T0::shape().name)(f, opts)?;
66 write!(f, ",")?;
67 (T1::shape().name)(f, opts)?;
68 write!(f, ")")
69 } else {
70 write!(f, "()")
71 }
72 },
73 typeid: mini_typeid::of::<Self>(),
74 layout: Layout::new::<(T0, T1)>(),
75 innards: Innards::Tuple {
76 fields: &const { [field!(0, T0), field!(1, T1)] },
77 },
78 set_to_default: None,
79 drop_in_place: Some(|addr: *mut u8| unsafe {
80 std::ptr::drop_in_place(addr as *mut (T0, T1));
81 }),
82 }
83 }
84}
85
86impl<T0, T1, T2> Shapely for (T0, T1, T2)
87where
88 T0: Shapely,
89 T1: Shapely,
90 T2: Shapely,
91{
92 fn shape() -> Shape {
93 macro_rules! field {
94 ($idx:tt, $ty:ty) => {
95 Field {
96 name: stringify!($idx),
97 shape: ShapeDesc(<$ty>::shape),
98 offset: std::mem::offset_of!((T0, T1, T2), $idx),
99 flags: FieldFlags::EMPTY,
100 }
101 };
102 }
103
104 Shape {
105 name: |f, opts| {
106 if let Some(opts) = opts.for_children() {
107 write!(f, "(")?;
108 (T0::shape().name)(f, opts)?;
109 write!(f, ",")?;
110 (T1::shape().name)(f, opts)?;
111 write!(f, ",")?;
112 (T2::shape().name)(f, opts)?;
113 write!(f, ")")
114 } else {
115 write!(f, "()")
116 }
117 },
118 typeid: mini_typeid::of::<Self>(),
119 layout: Layout::new::<(T0, T1, T2)>(),
120 innards: Innards::Tuple {
121 fields: &const { [field!(0, T0), field!(1, T1), field!(2, T2)] },
122 },
123 set_to_default: None,
124 drop_in_place: Some(|addr: *mut u8| unsafe {
125 std::ptr::drop_in_place(addr as *mut (T0, T1, T2));
126 }),
127 }
128 }
129}
130
131impl<T0, T1, T2, T3> Shapely for (T0, T1, T2, T3)
132where
133 T0: Shapely,
134 T1: Shapely,
135 T2: Shapely,
136 T3: Shapely,
137{
138 fn shape() -> Shape {
139 macro_rules! field {
140 ($idx:tt, $ty:ty) => {
141 Field {
142 name: stringify!($idx),
143 shape: ShapeDesc(<$ty>::shape),
144 offset: std::mem::offset_of!((T0, T1, T2, T3), $idx),
145 flags: FieldFlags::EMPTY,
146 }
147 };
148 }
149
150 Shape {
151 name: |f, opts| {
152 if let Some(opts) = opts.for_children() {
153 write!(f, "(")?;
154 (T0::shape().name)(f, opts)?;
155 write!(f, ",")?;
156 (T1::shape().name)(f, opts)?;
157 write!(f, ",")?;
158 (T2::shape().name)(f, opts)?;
159 write!(f, ",")?;
160 (T3::shape().name)(f, opts)?;
161 write!(f, ")")
162 } else {
163 write!(f, "()")
164 }
165 },
166 typeid: mini_typeid::of::<Self>(),
167 layout: Layout::new::<(T0, T1, T2, T3)>(),
168 innards: Innards::Tuple {
169 fields: &const { [field!(0, T0), field!(1, T1), field!(2, T2), field!(3, T3)] },
170 },
171 set_to_default: None,
172 drop_in_place: Some(|addr: *mut u8| unsafe {
173 std::ptr::drop_in_place(addr as *mut (T0, T1, T2, T3));
174 }),
175 }
176 }
177}
178
179impl<T0, T1, T2, T3, T4> Shapely for (T0, T1, T2, T3, T4)
180where
181 T0: Shapely,
182 T1: Shapely,
183 T2: Shapely,
184 T3: Shapely,
185 T4: Shapely,
186{
187 fn shape() -> Shape {
188 macro_rules! field {
189 ($idx:tt, $ty:ty) => {
190 Field {
191 name: stringify!($idx),
192 shape: ShapeDesc(<$ty>::shape),
193 offset: std::mem::offset_of!((T0, T1, T2, T3, T4), $idx),
194 flags: FieldFlags::EMPTY,
195 }
196 };
197 }
198
199 Shape {
200 name: |f, opts| {
201 if let Some(opts) = opts.for_children() {
202 write!(f, "(")?;
203 (T0::shape().name)(f, opts)?;
204 write!(f, ",")?;
205 (T1::shape().name)(f, opts)?;
206 write!(f, ",")?;
207 (T2::shape().name)(f, opts)?;
208 write!(f, ",")?;
209 (T3::shape().name)(f, opts)?;
210 write!(f, ",")?;
211 (T4::shape().name)(f, opts)?;
212 write!(f, ")")
213 } else {
214 write!(f, "()")
215 }
216 },
217 typeid: mini_typeid::of::<Self>(),
218 layout: Layout::new::<(T0, T1, T2, T3, T4)>(),
219 innards: Innards::Tuple {
220 fields: &const {
221 [
222 field!(0, T0),
223 field!(1, T1),
224 field!(2, T2),
225 field!(3, T3),
226 field!(4, T4),
227 ]
228 },
229 },
230 set_to_default: None,
231 drop_in_place: Some(|addr: *mut u8| unsafe {
232 std::ptr::drop_in_place(addr as *mut (T0, T1, T2, T3, T4));
233 }),
234 }
235 }
236}
237
238impl<T0, T1, T2, T3, T4, T5> Shapely for (T0, T1, T2, T3, T4, T5)
239where
240 T0: Shapely,
241 T1: Shapely,
242 T2: Shapely,
243 T3: Shapely,
244 T4: Shapely,
245 T5: Shapely,
246{
247 fn shape() -> Shape {
248 macro_rules! field {
249 ($idx:tt, $ty:ty) => {
250 Field {
251 name: stringify!($idx),
252 shape: ShapeDesc(<$ty>::shape),
253 offset: std::mem::offset_of!((T0, T1, T2, T3, T4, T5), $idx),
254 flags: FieldFlags::EMPTY,
255 }
256 };
257 }
258
259 Shape {
260 name: |f, opts| {
261 if let Some(opts) = opts.for_children() {
262 write!(f, "(")?;
263 (T0::shape().name)(f, opts)?;
264 write!(f, ",")?;
265 (T1::shape().name)(f, opts)?;
266 write!(f, ",")?;
267 (T2::shape().name)(f, opts)?;
268 write!(f, ",")?;
269 (T3::shape().name)(f, opts)?;
270 write!(f, ",")?;
271 (T4::shape().name)(f, opts)?;
272 write!(f, ",")?;
273 (T5::shape().name)(f, opts)?;
274 write!(f, ")")
275 } else {
276 write!(f, "()")
277 }
278 },
279 typeid: mini_typeid::of::<Self>(),
280 layout: Layout::new::<(T0, T1, T2, T3, T4, T5)>(),
281 innards: Innards::Tuple {
282 fields: &const {
283 [
284 field!(0, T0),
285 field!(1, T1),
286 field!(2, T2),
287 field!(3, T3),
288 field!(4, T4),
289 field!(5, T5),
290 ]
291 },
292 },
293 set_to_default: None,
294 drop_in_place: Some(|addr: *mut u8| unsafe {
295 std::ptr::drop_in_place(addr as *mut (T0, T1, T2, T3, T4, T5));
296 }),
297 }
298 }
299}
300
301impl<T0, T1, T2, T3, T4, T5, T6> Shapely for (T0, T1, T2, T3, T4, T5, T6)
302where
303 T0: Shapely,
304 T1: Shapely,
305 T2: Shapely,
306 T3: Shapely,
307 T4: Shapely,
308 T5: Shapely,
309 T6: Shapely,
310{
311 fn shape() -> Shape {
312 macro_rules! field {
313 ($idx:tt, $ty:ty) => {
314 Field {
315 name: stringify!($idx),
316 shape: ShapeDesc(<$ty>::shape),
317 offset: std::mem::offset_of!((T0, T1, T2, T3, T4, T5, T6), $idx),
318 flags: FieldFlags::EMPTY,
319 }
320 };
321 }
322
323 Shape {
324 name: |f, opts| {
325 if let Some(opts) = opts.for_children() {
326 write!(f, "(")?;
327 (T0::shape().name)(f, opts)?;
328 write!(f, ",")?;
329 (T1::shape().name)(f, opts)?;
330 write!(f, ",")?;
331 (T2::shape().name)(f, opts)?;
332 write!(f, ",")?;
333 (T3::shape().name)(f, opts)?;
334 write!(f, ",")?;
335 (T4::shape().name)(f, opts)?;
336 write!(f, ",")?;
337 (T5::shape().name)(f, opts)?;
338 write!(f, ",")?;
339 (T6::shape().name)(f, opts)?;
340 write!(f, ")")
341 } else {
342 write!(f, "()")
343 }
344 },
345 typeid: mini_typeid::of::<Self>(),
346 layout: Layout::new::<(T0, T1, T2, T3, T4, T5, T6)>(),
347 innards: Innards::Tuple {
348 fields: &const {
349 [
350 field!(0, T0),
351 field!(1, T1),
352 field!(2, T2),
353 field!(3, T3),
354 field!(4, T4),
355 field!(5, T5),
356 field!(6, T6),
357 ]
358 },
359 },
360 set_to_default: None,
361 drop_in_place: Some(|addr: *mut u8| unsafe {
362 std::ptr::drop_in_place(addr as *mut (T0, T1, T2, T3, T4, T5, T6));
363 }),
364 }
365 }
366}
367
368impl<T0, T1, T2, T3, T4, T5, T6, T7> Shapely for (T0, T1, T2, T3, T4, T5, T6, T7)
369where
370 T0: Shapely,
371 T1: Shapely,
372 T2: Shapely,
373 T3: Shapely,
374 T4: Shapely,
375 T5: Shapely,
376 T6: Shapely,
377 T7: Shapely,
378{
379 fn shape() -> Shape {
380 macro_rules! field {
381 ($idx:tt, $ty:ty) => {
382 Field {
383 name: stringify!($idx),
384 shape: ShapeDesc(<$ty>::shape),
385 offset: std::mem::offset_of!((T0, T1, T2, T3, T4, T5, T6, T7), $idx),
386 flags: FieldFlags::EMPTY,
387 }
388 };
389 }
390
391 Shape {
392 name: |f, opts| {
393 if let Some(opts) = opts.for_children() {
394 write!(f, "(")?;
395 (T0::shape().name)(f, opts)?;
396 write!(f, ",")?;
397 (T1::shape().name)(f, opts)?;
398 write!(f, ",")?;
399 (T2::shape().name)(f, opts)?;
400 write!(f, ",")?;
401 (T3::shape().name)(f, opts)?;
402 write!(f, ",")?;
403 (T4::shape().name)(f, opts)?;
404 write!(f, ",")?;
405 (T5::shape().name)(f, opts)?;
406 write!(f, ",")?;
407 (T6::shape().name)(f, opts)?;
408 write!(f, ",")?;
409 (T7::shape().name)(f, opts)?;
410 write!(f, ")")
411 } else {
412 write!(f, "()")
413 }
414 },
415 typeid: mini_typeid::of::<Self>(),
416 layout: Layout::new::<(T0, T1, T2, T3, T4, T5, T6, T7)>(),
417 innards: Innards::Tuple {
418 fields: &const {
419 [
420 field!(0, T0),
421 field!(1, T1),
422 field!(2, T2),
423 field!(3, T3),
424 field!(4, T4),
425 field!(5, T5),
426 field!(6, T6),
427 field!(7, T7),
428 ]
429 },
430 },
431 set_to_default: None,
432 drop_in_place: Some(|addr: *mut u8| unsafe {
433 std::ptr::drop_in_place(addr as *mut (T0, T1, T2, T3, T4, T5, T6, T7));
434 }),
435 }
436 }
437}
438
439impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> Shapely for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
440where
441 T0: Shapely,
442 T1: Shapely,
443 T2: Shapely,
444 T3: Shapely,
445 T4: Shapely,
446 T5: Shapely,
447 T6: Shapely,
448 T7: Shapely,
449 T8: Shapely,
450{
451 fn shape() -> Shape {
452 macro_rules! field {
453 ($idx:tt, $ty:ty) => {
454 Field {
455 name: stringify!($idx),
456 shape: ShapeDesc(<$ty>::shape),
457 offset: std::mem::offset_of!((T0, T1, T2, T3, T4, T5, T6, T7, T8), $idx),
458 flags: FieldFlags::EMPTY,
459 }
460 };
461 }
462
463 Shape {
464 name: |f, opts| {
465 if let Some(opts) = opts.for_children() {
466 write!(f, "(")?;
467 (T0::shape().name)(f, opts)?;
468 write!(f, ",")?;
469 (T1::shape().name)(f, opts)?;
470 write!(f, ",")?;
471 (T2::shape().name)(f, opts)?;
472 write!(f, ",")?;
473 (T3::shape().name)(f, opts)?;
474 write!(f, ",")?;
475 (T4::shape().name)(f, opts)?;
476 write!(f, ",")?;
477 (T5::shape().name)(f, opts)?;
478 write!(f, ",")?;
479 (T6::shape().name)(f, opts)?;
480 write!(f, ",")?;
481 (T7::shape().name)(f, opts)?;
482 write!(f, ",")?;
483 (T8::shape().name)(f, opts)?;
484 write!(f, ")")
485 } else {
486 write!(f, "()")
487 }
488 },
489 typeid: mini_typeid::of::<Self>(),
490 layout: Layout::new::<(T0, T1, T2, T3, T4, T5, T6, T7, T8)>(),
491 innards: Innards::Tuple {
492 fields: &const {
493 [
494 field!(0, T0),
495 field!(1, T1),
496 field!(2, T2),
497 field!(3, T3),
498 field!(4, T4),
499 field!(5, T5),
500 field!(6, T6),
501 field!(7, T7),
502 field!(8, T8),
503 ]
504 },
505 },
506 set_to_default: None,
507 drop_in_place: Some(|addr: *mut u8| unsafe {
508 std::ptr::drop_in_place(addr as *mut (T0, T1, T2, T3, T4, T5, T6, T7, T8));
509 }),
510 }
511 }
512}
513
514impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Shapely for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
515where
516 T0: Shapely,
517 T1: Shapely,
518 T2: Shapely,
519 T3: Shapely,
520 T4: Shapely,
521 T5: Shapely,
522 T6: Shapely,
523 T7: Shapely,
524 T8: Shapely,
525 T9: Shapely,
526{
527 fn shape() -> Shape {
528 macro_rules! field {
529 ($idx:tt, $ty:ty) => {
530 Field {
531 name: stringify!($idx),
532 shape: ShapeDesc(<$ty>::shape),
533 offset: std::mem::offset_of!((T0, T1, T2, T3, T4, T5, T6, T7, T8, T9), $idx),
534 flags: FieldFlags::EMPTY,
535 }
536 };
537 }
538
539 Shape {
540 name: |f, opts| {
541 if let Some(opts) = opts.for_children() {
542 write!(f, "(")?;
543 (T0::shape().name)(f, opts)?;
544 write!(f, ",")?;
545 (T1::shape().name)(f, opts)?;
546 write!(f, ",")?;
547 (T2::shape().name)(f, opts)?;
548 write!(f, ",")?;
549 (T3::shape().name)(f, opts)?;
550 write!(f, ",")?;
551 (T4::shape().name)(f, opts)?;
552 write!(f, ",")?;
553 (T5::shape().name)(f, opts)?;
554 write!(f, ",")?;
555 (T6::shape().name)(f, opts)?;
556 write!(f, ",")?;
557 (T7::shape().name)(f, opts)?;
558 write!(f, ",")?;
559 (T8::shape().name)(f, opts)?;
560 write!(f, ",")?;
561 (T9::shape().name)(f, opts)?;
562 write!(f, ")")
563 } else {
564 write!(f, "()")
565 }
566 },
567 typeid: mini_typeid::of::<Self>(),
568 layout: Layout::new::<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)>(),
569 innards: Innards::Tuple {
570 fields: &const {
571 [
572 field!(0, T0),
573 field!(1, T1),
574 field!(2, T2),
575 field!(3, T3),
576 field!(4, T4),
577 field!(5, T5),
578 field!(6, T6),
579 field!(7, T7),
580 field!(8, T8),
581 field!(9, T9),
582 ]
583 },
584 },
585 set_to_default: None,
586 drop_in_place: Some(|addr: *mut u8| unsafe {
587 std::ptr::drop_in_place(addr as *mut (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9));
588 }),
589 }
590 }
591}
592
593impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Shapely
594 for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
595where
596 T0: Shapely,
597 T1: Shapely,
598 T2: Shapely,
599 T3: Shapely,
600 T4: Shapely,
601 T5: Shapely,
602 T6: Shapely,
603 T7: Shapely,
604 T8: Shapely,
605 T9: Shapely,
606 T10: Shapely,
607{
608 fn shape() -> Shape {
609 macro_rules! field {
610 ($idx:tt, $ty:ty) => {
611 Field {
612 name: stringify!($idx),
613 shape: ShapeDesc(<$ty>::shape),
614 offset: std::mem::offset_of!(
615 (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10),
616 $idx
617 ),
618 flags: FieldFlags::EMPTY,
619 }
620 };
621 }
622
623 Shape {
624 name: |f, opts| {
625 if let Some(opts) = opts.for_children() {
626 write!(f, "(")?;
627 (T0::shape().name)(f, opts)?;
628 write!(f, ",")?;
629 (T1::shape().name)(f, opts)?;
630 write!(f, ",")?;
631 (T2::shape().name)(f, opts)?;
632 write!(f, ",")?;
633 (T3::shape().name)(f, opts)?;
634 write!(f, ",")?;
635 (T4::shape().name)(f, opts)?;
636 write!(f, ",")?;
637 (T5::shape().name)(f, opts)?;
638 write!(f, ",")?;
639 (T6::shape().name)(f, opts)?;
640 write!(f, ",")?;
641 (T7::shape().name)(f, opts)?;
642 write!(f, ",")?;
643 (T8::shape().name)(f, opts)?;
644 write!(f, ",")?;
645 (T9::shape().name)(f, opts)?;
646 write!(f, ",")?;
647 (T10::shape().name)(f, opts)?;
648 write!(f, ")")
649 } else {
650 write!(f, "()")
651 }
652 },
653 typeid: mini_typeid::of::<Self>(),
654 layout: Layout::new::<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>(),
655 innards: Innards::Tuple {
656 fields: &const {
657 [
658 field!(0, T0),
659 field!(1, T1),
660 field!(2, T2),
661 field!(3, T3),
662 field!(4, T4),
663 field!(5, T5),
664 field!(6, T6),
665 field!(7, T7),
666 field!(8, T8),
667 field!(9, T9),
668 field!(10, T10),
669 ]
670 },
671 },
672 set_to_default: None,
673 drop_in_place: Some(|addr: *mut u8| unsafe {
674 std::ptr::drop_in_place(addr as *mut (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10));
675 }),
676 }
677 }
678}
679
680impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Shapely
681 for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
682where
683 T0: Shapely,
684 T1: Shapely,
685 T2: Shapely,
686 T3: Shapely,
687 T4: Shapely,
688 T5: Shapely,
689 T6: Shapely,
690 T7: Shapely,
691 T8: Shapely,
692 T9: Shapely,
693 T10: Shapely,
694 T11: Shapely,
695{
696 fn shape() -> Shape {
697 macro_rules! field {
698 ($idx:tt, $ty:ty) => {
699 Field {
700 name: stringify!($idx),
701 shape: ShapeDesc(<$ty>::shape),
702 offset: std::mem::offset_of!(
703 (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11),
704 $idx
705 ),
706 flags: FieldFlags::EMPTY,
707 }
708 };
709 }
710
711 Shape {
712 name: |f, opts| {
713 if let Some(opts) = opts.for_children() {
714 write!(f, "(")?;
715 (T0::shape().name)(f, opts)?;
716 write!(f, ",")?;
717 (T1::shape().name)(f, opts)?;
718 write!(f, ",")?;
719 (T2::shape().name)(f, opts)?;
720 write!(f, ",")?;
721 (T3::shape().name)(f, opts)?;
722 write!(f, ",")?;
723 (T4::shape().name)(f, opts)?;
724 write!(f, ",")?;
725 (T5::shape().name)(f, opts)?;
726 write!(f, ",")?;
727 (T6::shape().name)(f, opts)?;
728 write!(f, ",")?;
729 (T7::shape().name)(f, opts)?;
730 write!(f, ",")?;
731 (T8::shape().name)(f, opts)?;
732 write!(f, ",")?;
733 (T9::shape().name)(f, opts)?;
734 write!(f, ",")?;
735 (T10::shape().name)(f, opts)?;
736 write!(f, ",")?;
737 (T11::shape().name)(f, opts)?;
738 write!(f, ")")
739 } else {
740 write!(f, "()")
741 }
742 },
743 typeid: mini_typeid::of::<Self>(),
744 layout: Layout::new::<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>(),
745 innards: Innards::Tuple {
746 fields: &const {
747 [
748 field!(0, T0),
749 field!(1, T1),
750 field!(2, T2),
751 field!(3, T3),
752 field!(4, T4),
753 field!(5, T5),
754 field!(6, T6),
755 field!(7, T7),
756 field!(8, T8),
757 field!(9, T9),
758 field!(10, T10),
759 field!(11, T11),
760 ]
761 },
762 },
763 set_to_default: None,
764 drop_in_place: Some(|addr: *mut u8| unsafe {
765 std::ptr::drop_in_place(
766 addr as *mut (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11),
767 );
768 }),
769 }
770 }
771}