1#![deny(warnings)]
11#![doc(test(attr(deny(warnings))))]
12#![doc(test(attr(allow(unknown_lints))))]
13#![doc(test(attr(allow(dead_code))))]
14#![doc(test(attr(allow(unused_variables))))]
15#![doc(test(attr(allow(unused_macros))))]
16#![doc(test(attr(allow(non_local_definitions))))]
17
18#![no_std]
185
186#[doc(hidden)]
187pub use core::convert::From as std_convert_From;
188#[doc(hidden)]
189pub use core::fmt::Binary as std_fmt_Binary;
190#[doc(hidden)]
191pub use core::fmt::Debug as std_fmt_Debug;
192#[doc(hidden)]
193pub use core::fmt::Display as std_fmt_Display;
194#[doc(hidden)]
195pub use core::fmt::Formatter as std_fmt_Formatter;
196#[doc(hidden)]
197pub use core::fmt::LowerExp as std_fmt_LowerExp;
198#[doc(hidden)]
199pub use core::fmt::LowerHex as std_fmt_LowerHex;
200#[doc(hidden)]
201pub use core::fmt::Octal as std_fmt_Octal;
202#[doc(hidden)]
203pub use core::fmt::Pointer as std_fmt_Pointer;
204#[doc(hidden)]
205pub use core::fmt::UpperExp as std_fmt_UpperExp;
206#[doc(hidden)]
207pub use core::fmt::UpperHex as std_fmt_UpperHex;
208#[doc(hidden)]
209pub use core::fmt::Result as std_fmt_Result;
210#[doc(hidden)]
211pub use core::ops::Add as std_ops_Add;
212#[doc(hidden)]
213pub use core::ops::BitAnd as std_ops_BitAnd;
214#[doc(hidden)]
215pub use core::ops::BitOr as std_ops_BitOr;
216#[doc(hidden)]
217pub use core::ops::BitXor as std_ops_BitXor;
218#[doc(hidden)]
219pub use core::ops::Deref as std_ops_Deref;
220#[doc(hidden)]
221pub use core::ops::DerefMut as std_ops_DerefMut;
222#[doc(hidden)]
223pub use core::ops::Div as std_ops_Div;
224#[doc(hidden)]
225pub use core::ops::Index as std_ops_Index;
226#[doc(hidden)]
227pub use core::ops::IndexMut as std_ops_IndexMut;
228#[doc(hidden)]
229pub use core::ops::Mul as std_ops_Mul;
230#[doc(hidden)]
231pub use core::ops::Neg as std_ops_Neg;
232#[doc(hidden)]
233pub use core::ops::Not as std_ops_Not;
234#[doc(hidden)]
235pub use core::ops::Rem as std_ops_Rem;
236#[doc(hidden)]
237pub use core::ops::Shl as std_ops_Shl;
238#[doc(hidden)]
239pub use core::ops::Shr as std_ops_Shr;
240#[doc(hidden)]
241pub use core::ops::Sub as std_ops_Sub;
242#[doc(hidden)]
243pub use generics::concat as generics_concat;
244#[doc(hidden)]
245pub use generics::parse as generics_parse;
246
247#[doc(hidden)]
248#[macro_export]
249macro_rules! def_lt_a {
250 (
251 [] $callback:path { $($args:tt)* }
252 ) => {
253 $callback ! {
254 ['newtype_derive_a] $($args)*
255 }
256 };
257 (
258 [$a:lifetime] $callback:path { $($args:tt)* }
259 ) => {
260 $callback ! {
261 [$a] $($args)*
262 }
263 };
264}
265
266#[doc(hidden)]
267#[macro_export]
268macro_rules! def_lt_a_b {
269 (
270 [] [] $callback:path { $($args:tt)* }
271 ) => {
272 $callback ! {
273 ['newtype_derive_a] ['newtype_derive_b] $($args)*
274 }
275 };
276 (
277 [$a:lifetime] [] $callback:path { $($args:tt)* }
278 ) => {
279 $callback ! {
280 [$a] ['newtype_derive_b] $($args)*
281 }
282 };
283 (
284 [] [$b:lifetime] $callback:path { $($args:tt)* }
285 ) => {
286 $callback ! {
287 ['newtype_derive_a] [$b] $($args)*
288 }
289 };
290 (
291 [$a:lifetime] [$b:lifetime] $callback:path { $($args:tt)* }
292 ) => {
293 $callback ! {
294 [$a] [$b] $($args)*
295 }
296 };
297}
298
299#[doc(hidden)]
300#[macro_export]
301macro_rules! as_item {
302 ($i:item) => {$i};
303}
304
305#[doc(hidden)]
306#[macro_export]
307macro_rules! wrap_bin_op {
308 (
309 trait: ($($tr:tt)*)::$meth:ident,
310 kind: simple,
311 item: [$name:ident] [$($bound:tt)*] [$($body:tt)+]
312 ) => {
313 $crate::generics_parse! {
314 $crate::wrap_bin_op {
315 generics_parse_done
316 [
317 trait: ($($tr)*)::$meth,
318 kind: simple,
319 item: [$name] [$($bound)*]
320 ]
321 }
322 $($body)+
323 }
324 };
325 (
326 generics_parse_done
327 [
328 trait: ($($tr:tt)*)::$meth:ident,
329 kind: simple,
330 item: [$name:ident] [$($bound:tt)*]
331 ]
332 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
333 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
334 ) => {
335 $crate::generics_concat! {
336 $crate::wrap_bin_op {
337 generics_concat_done
338 [
339 trait: ($($tr)*)::$meth,
340 kind: simple,
341 item: [$name] [$t0] [$([$phantom])*]
342 ]
343 }
344 [$($g)*] [$($r)*] [$($w)*],
345 [] [] [where $($bound)*]
346 }
347 };
348 (
349 generics_concat_done
350 [
351 trait: ($($tr:tt)*)::$meth:ident,
352 kind: simple,
353 item: [$name:ident] [$t0:ty] [$([$phantom:ty])*]
354 ]
355 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
356 ) => {
357 $crate::as_item! {
358 impl $($g)* $($tr)*<$name $($r)*> for $name $($r)* $($w)* {
359 type Output = Self;
360 fn $meth(self, rhs: Self) -> Self {
361 $name(
362 <$t0 as $($tr)*<$t0>>::$meth(self.0, rhs.0)
363 $(, <$phantom as $crate::std_default_Default>::default())*
364 )
365 }
366 }
367 }
368 };
369
370 (
371 [$a:lifetime]
372 trait: ($($tr:tt)*)::$meth:ident,
373 kind: simple_ref,
374 item: [$name:ident] [$($bound:tt)*] [$($body:tt)+]
375 ) => {
376 $crate::generics_parse! {
377 $crate::wrap_bin_op {
378 generics_parse_done
379 [
380 trait: ($($tr)*)::$meth,
381 kind: simple_ref,
382 item: [$a] [$name] [$($bound)*]
383 ]
384 }
385 $($body)+
386 }
387 };
388 (
389 generics_parse_done
390 [
391 trait: ($($tr:tt)*)::$meth:ident,
392 kind: simple_ref,
393 item: [$a:lifetime] [$name:ident] [$($bound:tt)*]
394 ]
395 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
396 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
397 ) => {
398 $crate::generics_concat! {
399 $crate::wrap_bin_op {
400 generics_concat_done
401 [
402 trait: ($($tr)*)::$meth,
403 kind: simple_ref,
404 item: [$a] [$name] [$t0] [$([$phantom])*]
405 ]
406 }
407 [ < $a > ] [] [],
408 [$($g)*] [$($r)*] [$($w)*],
409 [] [] [where $($bound)*]
410 }
411 };
412 (
413 generics_concat_done
414 [
415 trait: ($($tr:tt)*)::$meth:ident,
416 kind: simple_ref,
417 item: [$a:lifetime] [$name:ident] [$t0:ty] [$([$phantom:ty])*]
418 ]
419 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
420 ) => {
421 $crate::as_item! {
422 impl $($g)* $($tr)*<$name $($r)*> for & $a $name $($r)* $($w)* {
423 type Output = $name $($r)*;
424 fn $meth(self, rhs: $name $($r)*) -> $name $($r)* {
425 $name(
426 <$t0 as $($tr)*<$t0>>::$meth(self.0, rhs.0)
427 $(, <$phantom as $crate::std_default_Default>::default())*
428 )
429 }
430 }
431 }
432 };
433
434 (
435 [$a:lifetime]
436 trait: ($($tr:tt)*)::$meth:ident,
437 kind: rhs_rewrap(&Self),
438 item: [$name:ident] [$($bound:tt)*] [$($body:tt)+]
439 ) => {
440 $crate::generics_parse! {
441 $crate::wrap_bin_op {
442 generics_parse_done
443 [
444 trait: ($($tr)*)::$meth,
445 kind: rhs_rewrap(&Self),
446 item: [$a] [$name] [$($bound)*]
447 ]
448 }
449 $($body)+
450 }
451 };
452 (
453 generics_parse_done
454 [
455 trait: ($($tr:tt)*)::$meth:ident,
456 kind: rhs_rewrap(&Self),
457 item: [$a:lifetime] [$name:ident] [$($bound:tt)*]
458 ]
459 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
460 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
461 ) => {
462 $crate::generics_concat! {
463 $crate::wrap_bin_op {
464 generics_concat_done
465 [
466 trait: ($($tr)*)::$meth,
467 kind: rhs_rewrap(&Self),
468 item: [$a] [$name] [$t0] [$([$phantom])*]
469 ]
470 }
471 [ < $a > ] [] [],
472 [$($g)*] [$($r)*] [$($w)*],
473 [] [] [where $($bound)*]
474 }
475 };
476 (
477 generics_concat_done
478 [
479 trait: ($($tr:tt)*)::$meth:ident,
480 kind: rhs_rewrap(&Self),
481 item: [$a:lifetime] [$name:ident] [$t0:ty] [$([$phantom:ty])*]
482 ]
483 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
484 ) => {
485 $crate::as_item! {
486 impl $($g)* $($tr)*<& $a $name $($r)*> for $name $($r)* $($w)* {
487 type Output = Self;
488 fn $meth(self, rhs: & $a Self) -> Self {
489 $name(
490 <$t0 as $($tr)*<$t0>>::$meth(self.0, rhs.0)
491 $(, <$phantom as $crate::std_default_Default>::default())*
492 )
493 }
494 }
495 }
496 };
497
498 (
499 trait: ($($tr:tt)*)::$meth:ident,
500 kind: rhs_rewrap($Rhs:ty),
501 item: [$name:ident] [$($lt:tt)*] [$($T:tt)*] [$($bound:tt)*] [$($body:tt)+]
502 ) => {
503 $crate::generics_parse! {
504 $crate::wrap_bin_op {
505 generics_parse_done
506 [
507 trait: ($($tr)*)::$meth,
508 kind: rhs_rewrap($Rhs),
509 item: [$name] [$($lt)*] [$($T)*] [$($bound)*]
510 ]
511 }
512 $($body)+
513 }
514 };
515 (
516 generics_parse_done
517 [
518 trait: ($($tr:tt)*)::$meth:ident,
519 kind: rhs_rewrap($Rhs:ty),
520 item: [$name:ident] [$($lt:tt)*] [$($T:tt)*] [$($bound:tt)*]
521 ]
522 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
523 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
524 ) => {
525 $crate::generics_concat! {
526 $crate::wrap_bin_op {
527 generics_concat_done
528 [
529 trait: ($($tr)*)::$meth,
530 kind: rhs_rewrap($Rhs),
531 item: [$name] [$t0] [$([$phantom])*]
532 ]
533 }
534 [$($lt)*] [] [],
535 [$($g)*] [$($r)*] [$($w)*],
536 [$($T)*] [] [],
537 [] [] [where $($bound)*]
538 }
539 };
540 (
541 generics_concat_done
542 [
543 trait: ($($tr:tt)*)::$meth:ident,
544 kind: rhs_rewrap($Rhs:ty),
545 item: [$name:ident] [$t0:ty] [$([$phantom:ty])*]
546 ]
547 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
548 ) => {
549 $crate::as_item! {
550 impl $($g)* $($tr)*<$Rhs> for $name $($r)* $($w)* {
551 type Output = Self;
552 fn $meth(self, rhs: $Rhs) -> Self {
553 $name(
554 <$t0 as $($tr)*<$Rhs>>::$meth(self.0, rhs)
555 $(, <$phantom as $crate::std_default_Default>::default())*
556 )
557 }
558 }
559 }
560 };
561
562 (
563 [$a:lifetime] [$b:lifetime]
564 trait: ($($tr:tt)*)::$meth:ident,
565 kind: ref_rhs_rewrap(&Self),
566 item: [$name:ident] [$($bound:tt)*] [$($body:tt)+]
567 ) => {
568 $crate::generics_parse! {
569 $crate::wrap_bin_op {
570 generics_parse_done
571 [
572 trait: ($($tr)*)::$meth,
573 kind: ref_rhs_rewrap(&Self),
574 item: [$a] [$b] [$name] [$($bound)*]
575 ]
576 }
577 $($body)+
578 }
579 };
580 (
581 generics_parse_done
582 [
583 trait: ($($tr:tt)*)::$meth:ident,
584 kind: ref_rhs_rewrap(&Self),
585 item: [$a:lifetime] [$b:lifetime] [$name:ident] [$($bound:tt)*]
586 ]
587 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
588 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
589 ) => {
590 $crate::generics_concat! {
591 $crate::wrap_bin_op {
592 generics_concat_done
593 [
594 trait: ($($tr)*)::$meth,
595 kind: ref_rhs_rewrap(&Self),
596 item: [$a] [$b] [$name] [$t0] [$([$phantom])*]
597 ]
598 }
599 [ < $a, $b > ] [] [],
600 [$($g)*] [$($r)*] [$($w)*],
601 [] [] [where $($bound)*]
602 }
603 };
604 (
605 generics_concat_done
606 [
607 trait: ($($tr:tt)*)::$meth:ident,
608 kind: ref_rhs_rewrap(&Self),
609 item: [$a:lifetime] [$b:lifetime] [$name:ident] [$t0:ty] [$([$phantom:ty])*]
610 ]
611 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
612 ) => {
613 $crate::as_item! {
614 impl $($g)* $($tr)*<& $b $name $($r)*> for & $a $name $($r)* $($w)* {
615 type Output = $name $($r)*;
616 fn $meth(self, rhs: & $b $name $($r)*) -> $name $($r)* {
617 $name(
618 <$t0 as $($tr)*<$t0>>::$meth(self.0, rhs.0)
619 $(, <$phantom as $crate::std_default_Default>::default())*
620 )
621 }
622 }
623 }
624 };
625
626 (
627 [$a:lifetime]
628 trait: ($($tr:tt)*)::$meth:ident,
629 kind: ref_rhs_rewrap($Rhs:ty),
630 item: [$name:ident] [$($lt:tt)*] [$($T:tt)*] [$($bound:tt)*] [$($body:tt)+]
631 ) => {
632 $crate::generics_parse! {
633 $crate::wrap_bin_op {
634 generics_parse_done
635 [
636 trait: ($($tr)*)::$meth,
637 kind: ref_rhs_rewrap($Rhs),
638 item: [$a] [$name] [$($lt)*] [$($T)*] [$($bound)*]
639 ]
640 }
641 $($body)+
642 }
643 };
644 (
645 generics_parse_done
646 [
647 trait: ($($tr:tt)*)::$meth:ident,
648 kind: ref_rhs_rewrap($Rhs:ty),
649 item: [$a:lifetime] [$name:ident] [$($lt:tt)*] [$($T:tt)*] [$($bound:tt)*]
650 ]
651 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
652 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
653 ) => {
654 $crate::generics_concat! {
655 $crate::wrap_bin_op {
656 generics_concat_done
657 [
658 trait: ($($tr)*)::$meth,
659 kind: ref_rhs_rewrap($Rhs),
660 item: [$a] [$name] [$t0] [$([$phantom])*]
661 ]
662 }
663 [ < $a > ] [] [],
664 [$($lt)*] [] [],
665 [$($g)*] [$($r)*] [$($w)*],
666 [$($T)*] [] [],
667 [] [] [where $($bound)*]
668 }
669 };
670 (
671 generics_concat_done
672 [
673 trait: ($($tr:tt)*)::$meth:ident,
674 kind: ref_rhs_rewrap($Rhs:ty),
675 item: [$a:lifetime] [$name:ident] [$t0:ty] [$([$phantom:ty])*]
676 ]
677 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
678 ) => {
679 $crate::as_item! {
680 impl $($g)* $($tr)*<$Rhs> for & $a $name $($r)* $($w)* {
681 type Output = $name $($r)*;
682 fn $meth(self, rhs: $Rhs) -> $name $($r)* {
683 $name(
684 <$t0 as $($tr)*<$Rhs>>::$meth(self.0, rhs)
685 $(, <$phantom as $crate::std_default_Default>::default())*
686 )
687 }
688 }
689 }
690 };
691}
692
693#[macro_export]
792macro_rules! NewtypeAdd {
793 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
794 $crate::NewtypeAdd! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
795 $crate::NewtypeAdd! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
796 $crate::NewtypeAdd! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
797 $crate::NewtypeAdd! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
798 };
799 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
800 $crate::wrap_bin_op! { trait: ($crate::std_ops_Add)::add, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
801 };
802 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
803 $crate::def_lt_a! {
804 [$($a)?]
805 $crate::wrap_bin_op { trait: ($crate::std_ops_Add)::add, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
806 }
807 };
808 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
809 $crate::def_lt_a_b! {
810 [$($a)?] [$($b)?]
811 $crate::wrap_bin_op { trait: ($crate::std_ops_Add)::add, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
812 }
813 };
814 (($(<$($($T:ident),+ $(,)?)?>)? & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
815 $crate::def_lt_a! {
816 [$($a)?]
817 $crate::wrap_bin_op { trait: ($crate::std_ops_Add)::add, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
818 }
819 };
820 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
821 $crate::def_lt_a! {
822 [$($a)?]
823 $crate::wrap_bin_op { trait: ($crate::std_ops_Add)::add, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
824 }
825 };
826 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
827 $crate::def_lt_a! {
828 [$($a)?]
829 $crate::wrap_bin_op { trait: ($crate::std_ops_Add)::add, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
830 }
831 };
832 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
833 $crate::wrap_bin_op! { trait: ($crate::std_ops_Add)::add, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
834 };
835 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
836 $crate::wrap_bin_op! { trait: ($crate::std_ops_Add)::add, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
837 };
838}
839
840#[macro_export]
939macro_rules! NewtypeBitAnd {
940 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
941 $crate::NewtypeBitAnd! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
942 $crate::NewtypeBitAnd! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
943 $crate::NewtypeBitAnd! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
944 $crate::NewtypeBitAnd! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
945 };
946 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
947 $crate::wrap_bin_op! { trait: ($crate::std_ops_BitAnd)::bitand, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
948 };
949 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
950 $crate::def_lt_a! {
951 [$($a)?]
952 $crate::wrap_bin_op { trait: ($crate::std_ops_BitAnd)::bitand, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
953 }
954 };
955 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
956 $crate::def_lt_a_b! {
957 [$($a)?] [$($b)?]
958 $crate::wrap_bin_op { trait: ($crate::std_ops_BitAnd)::bitand, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
959 }
960 };
961 (($(<$($($T:ident),+ $(,)?)?>)? & $a:lifetime self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
962 $crate::def_lt_a! {
963 [$($a)?]
964 $crate::wrap_bin_op { trait: ($crate::std_ops_BitAnd)::bitand, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
965 }
966 };
967 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
968 $crate::def_lt_a! {
969 [$($a)?]
970 $crate::wrap_bin_op { trait: ($crate::std_ops_BitAnd)::bitand, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
971 }
972 };
973 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
974 $crate::def_lt_a! {
975 [$($a)?]
976 $crate::wrap_bin_op { trait: ($crate::std_ops_BitAnd)::bitand, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
977 }
978 };
979 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
980 $crate::wrap_bin_op! { trait: ($crate::std_ops_BitAnd)::bitand, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
981 };
982 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
983 $crate::wrap_bin_op! { trait: ($crate::std_ops_BitAnd)::bitand, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
984 };
985}
986
987#[macro_export]
1086macro_rules! NewtypeBitOr {
1087 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1088 $crate::NewtypeBitOr! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
1089 $crate::NewtypeBitOr! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
1090 $crate::NewtypeBitOr! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1091 $crate::NewtypeBitOr! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1092 };
1093 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1094 $crate::wrap_bin_op! { trait: ($crate::std_ops_BitOr)::bitor, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
1095 };
1096 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1097 $crate::def_lt_a! {
1098 [$($a)?]
1099 $crate::wrap_bin_op { trait: ($crate::std_ops_BitOr)::bitor, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
1100 }
1101 };
1102 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1103 $crate::def_lt_a_b! {
1104 [$($a)?] [$($b)?]
1105 $crate::wrap_bin_op { trait: ($crate::std_ops_BitOr)::bitor, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1106 }
1107 };
1108 (($(<$($($T:ident),+ $(,)?)?>)? & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1109 $crate::def_lt_a! {
1110 [$($a)?]
1111 $crate::wrap_bin_op { trait: ($crate::std_ops_BitOr)::bitor, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1112 }
1113 };
1114 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1115 $crate::def_lt_a! {
1116 [$($a)?]
1117 $crate::wrap_bin_op { trait: ($crate::std_ops_BitOr)::bitor, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1118 }
1119 };
1120 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1121 $crate::def_lt_a! {
1122 [$($a)?]
1123 $crate::wrap_bin_op { trait: ($crate::std_ops_BitOr)::bitor, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1124 }
1125 };
1126 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1127 $crate::wrap_bin_op! { trait: ($crate::std_ops_BitOr)::bitor, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1128 };
1129 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1130 $crate::wrap_bin_op! { trait: ($crate::std_ops_BitOr)::bitor, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1131 };
1132}
1133
1134#[macro_export]
1233macro_rules! NewtypeBitXor {
1234 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1235 $crate::NewtypeBitXor! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
1236 $crate::NewtypeBitXor! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
1237 $crate::NewtypeBitXor! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1238 $crate::NewtypeBitXor! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1239 };
1240 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1241 $crate::wrap_bin_op! { trait: ($crate::std_ops_BitXor)::bitxor, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
1242 };
1243 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1244 $crate::def_lt_a! {
1245 [$($a)?]
1246 $crate::wrap_bin_op { trait: ($crate::std_ops_BitXor)::bitxor, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
1247 }
1248 };
1249 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1250 $crate::def_lt_a_b! {
1251 [$($a)?] [$($b)?]
1252 $crate::wrap_bin_op { trait: ($crate::std_ops_BitXor)::bitxor, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1253 }
1254 };
1255 (($(<$($($T:ident),+ $(,)?)?>)? & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1256 $crate::def_lt_a! {
1257 [$($a)?]
1258 $crate::wrap_bin_op { trait: ($crate::std_ops_BitXor)::bitxor, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1259 }
1260 };
1261 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1262 $crate::def_lt_a! {
1263 [$($a)?]
1264 $crate::wrap_bin_op { trait: ($crate::std_ops_BitXor)::bitxor, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1265 }
1266 };
1267 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1268 $crate::def_lt_a! {
1269 [$($a)?]
1270 $crate::wrap_bin_op { trait: ($crate::std_ops_BitXor)::bitxor, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1271 }
1272 };
1273 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1274 $crate::wrap_bin_op! { trait: ($crate::std_ops_BitXor)::bitxor, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1275 };
1276 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1277 $crate::wrap_bin_op! { trait: ($crate::std_ops_BitXor)::bitxor, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1278 };
1279}
1280
1281#[macro_export]
1380macro_rules! NewtypeDiv {
1381 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1382 $crate::NewtypeDiv! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
1383 $crate::NewtypeDiv! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
1384 $crate::NewtypeDiv! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1385 $crate::NewtypeDiv! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1386 };
1387 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1388 $crate::wrap_bin_op! { trait: ($crate::std_ops_Div)::div, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
1389 };
1390 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1391 $crate::def_lt_a! {
1392 [$($a)?]
1393 $crate::wrap_bin_op { trait: ($crate::std_ops_Div)::div, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
1394 }
1395 };
1396 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1397 $crate::def_lt_a_b! {
1398 [$($a)?] [$($b)?]
1399 $crate::wrap_bin_op { trait: ($crate::std_ops_Div)::div, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1400 }
1401 };
1402 (($(<$($($T:ident),+ $(,)?)?>)? & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1403 $crate::def_lt_a! {
1404 [$($a)?]
1405 $crate::wrap_bin_op { trait: ($crate::std_ops_Div)::div, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1406 }
1407 };
1408 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1409 $crate::def_lt_a! {
1410 [$($a)?]
1411 $crate::wrap_bin_op { trait: ($crate::std_ops_Div)::div, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1412 }
1413 };
1414 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1415 $crate::def_lt_a! {
1416 [$($a)?]
1417 $crate::wrap_bin_op { trait: ($crate::std_ops_Div)::div, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1418 }
1419 };
1420 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1421 $crate::wrap_bin_op! { trait: ($crate::std_ops_Div)::div, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1422 };
1423 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1424 $crate::wrap_bin_op! { trait: ($crate::std_ops_Div)::div, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1425 };
1426}
1427
1428#[macro_export]
1527macro_rules! NewtypeMul {
1528 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1529 $crate::NewtypeMul! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
1530 $crate::NewtypeMul! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
1531 $crate::NewtypeMul! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1532 $crate::NewtypeMul! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1533 };
1534 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1535 $crate::wrap_bin_op! { trait: ($crate::std_ops_Mul)::mul, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
1536 };
1537 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1538 $crate::def_lt_a! {
1539 [$($a)?]
1540 $crate::wrap_bin_op { trait: ($crate::std_ops_Mul)::mul, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
1541 }
1542 };
1543 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1544 $crate::def_lt_a_b! {
1545 [$($a)?] [$($b)?]
1546 $crate::wrap_bin_op { trait: ($crate::std_ops_Mul)::mul, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1547 }
1548 };
1549 (($(<$($($T:ident),+ $(,)?)?>)? & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1550 $crate::def_lt_a! {
1551 [$($a)?]
1552 $crate::wrap_bin_op { trait: ($crate::std_ops_Mul)::mul, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1553 }
1554 };
1555 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1556 $crate::def_lt_a! {
1557 [$($a)?]
1558 $crate::wrap_bin_op { trait: ($crate::std_ops_Mul)::mul, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1559 }
1560 };
1561 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1562 $crate::def_lt_a! {
1563 [$($a)?]
1564 $crate::wrap_bin_op { trait: ($crate::std_ops_Mul)::mul, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1565 }
1566 };
1567 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1568 $crate::wrap_bin_op! { trait: ($crate::std_ops_Mul)::mul, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1569 };
1570 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1571 $crate::wrap_bin_op! { trait: ($crate::std_ops_Mul)::mul, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1572 };
1573}
1574
1575#[macro_export]
1674macro_rules! NewtypeRem {
1675 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1676 $crate::NewtypeRem! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
1677 $crate::NewtypeRem! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
1678 $crate::NewtypeRem! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1679 $crate::NewtypeRem! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1680 };
1681 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1682 $crate::wrap_bin_op! { trait: ($crate::std_ops_Rem)::rem, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
1683 };
1684 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1685 $crate::def_lt_a! {
1686 [$($a)?]
1687 $crate::wrap_bin_op { trait: ($crate::std_ops_Rem)::rem, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
1688 }
1689 };
1690 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1691 $crate::def_lt_a_b! {
1692 [$($a)?] [$($b)?]
1693 $crate::wrap_bin_op { trait: ($crate::std_ops_Rem)::rem, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1694 }
1695 };
1696 (($(<$($($T:ident),+ $(,)?)?>)? & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1697 $crate::def_lt_a! {
1698 [$($a)?]
1699 $crate::wrap_bin_op { trait: ($crate::std_ops_Rem)::rem, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1700 }
1701 };
1702 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1703 $crate::def_lt_a! {
1704 [$($a)?]
1705 $crate::wrap_bin_op { trait: ($crate::std_ops_Rem)::rem, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1706 }
1707 };
1708 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1709 $crate::def_lt_a! {
1710 [$($a)?]
1711 $crate::wrap_bin_op { trait: ($crate::std_ops_Rem)::rem, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1712 }
1713 };
1714 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1715 $crate::wrap_bin_op! { trait: ($crate::std_ops_Rem)::rem, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1716 };
1717 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1718 $crate::wrap_bin_op! { trait: ($crate::std_ops_Rem)::rem, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1719 };
1720}
1721
1722#[macro_export]
1821macro_rules! NewtypeSub {
1822 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1823 $crate::NewtypeSub! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
1824 $crate::NewtypeSub! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
1825 $crate::NewtypeSub! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1826 $crate::NewtypeSub! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1827 };
1828 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1829 $crate::wrap_bin_op! { trait: ($crate::std_ops_Sub)::sub, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
1830 };
1831 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1832 $crate::def_lt_a! {
1833 [$($a)?]
1834 $crate::wrap_bin_op { trait: ($crate::std_ops_Sub)::sub, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
1835 }
1836 };
1837 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1838 $crate::def_lt_a_b! {
1839 [$($a)?] [$($b)?]
1840 $crate::wrap_bin_op { trait: ($crate::std_ops_Sub)::sub, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1841 }
1842 };
1843 (($(<$($($T:ident),+ $(,)?)?>)? & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1844 $crate::def_lt_a! {
1845 [$($a)?]
1846 $crate::wrap_bin_op! { trait: ($crate::std_ops_Sub)::sub, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1847 }
1848 };
1849 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1850 $crate::def_lt_a! {
1851 [$($a)?]
1852 $crate::wrap_bin_op { trait: ($crate::std_ops_Sub)::sub, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1853 }
1854 };
1855 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1856 $crate::def_lt_a! {
1857 [$($a)?]
1858 $crate::wrap_bin_op { trait: ($crate::std_ops_Sub)::sub, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1859 }
1860 };
1861 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1862 $crate::wrap_bin_op! { trait: ($crate::std_ops_Sub)::sub, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1863 };
1864 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1865 $crate::wrap_bin_op! { trait: ($crate::std_ops_Sub)::sub, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
1866 };
1867}
1868
1869#[macro_export]
1968macro_rules! NewtypeShl {
1969 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1970 $crate::NewtypeShl! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
1971 $crate::NewtypeShl! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
1972 $crate::NewtypeShl! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1973 $crate::NewtypeShl! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
1974 };
1975 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1976 $crate::wrap_bin_op! { trait: ($crate::std_ops_Shl)::shl, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
1977 };
1978 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1979 $crate::def_lt_a! {
1980 [$($a)?]
1981 $crate::wrap_bin_op { trait: ($crate::std_ops_Shl)::shl, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
1982 }
1983 };
1984 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1985 $crate::def_lt_a_b! {
1986 [$($a)?] [$($b)?]
1987 $crate::wrap_bin_op { trait: ($crate::std_ops_Shl)::shl, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
1988 }
1989 };
1990 (($(<$($($T:ident),+ $(,)?)?>)? & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1991 $crate::def_lt_a! {
1992 [$($a)?]
1993 $crate::wrap_bin_op { trait: ($crate::std_ops_Shl)::shl, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
1994 }
1995 };
1996 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
1997 $crate::def_lt_a! {
1998 [$($a)?]
1999 $crate::wrap_bin_op { trait: ($crate::std_ops_Shl)::shl, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
2000 }
2001 };
2002 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2003 $crate::def_lt_a! {
2004 [$($a)?]
2005 $crate::wrap_bin_op { trait: ($crate::std_ops_Shl)::shl, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
2006 }
2007 };
2008 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2009 $crate::wrap_bin_op! { trait: ($crate::std_ops_Shl)::shl, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
2010 };
2011 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2012 $crate::wrap_bin_op! { trait: ($crate::std_ops_Shl)::shl, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
2013 };
2014}
2015
2016#[macro_export]
2115macro_rules! NewtypeShr {
2116 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2117 $crate::NewtypeShr! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
2118 $crate::NewtypeShr! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
2119 $crate::NewtypeShr! { (&Self $(where $($bound)*)?) $vis struct $name $($token)+ }
2120 $crate::NewtypeShr! { (&self, &Self $(where $($bound)*)?) $vis struct $name $($token)+ }
2121 };
2122 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2123 $crate::wrap_bin_op! { trait: ($crate::std_ops_Shr)::shr, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
2124 };
2125 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2126 $crate::def_lt_a! {
2127 [$($a)?]
2128 $crate::wrap_bin_op { trait: ($crate::std_ops_Shr)::shr, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
2129 }
2130 };
2131 ((& $($a:lifetime)? self, & $($b:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2132 $crate::def_lt_a_b! {
2133 [$($a)?] [$($b)?]
2134 $crate::wrap_bin_op { trait: ($crate::std_ops_Shr)::shr, kind: ref_rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
2135 }
2136 };
2137 (($(<$($($T:ident),+ $(,)?)?>)? & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2138 $crate::def_lt_a! {
2139 [$($a)?]
2140 $crate::wrap_bin_op { trait: ($crate::std_ops_Shr)::shr, kind: ref_rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
2141 }
2142 };
2143 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> & $($a:lifetime)? self, $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2144 $crate::def_lt_a! {
2145 [$($a)?]
2146 $crate::wrap_bin_op { trait: ($crate::std_ops_Shr)::shr, kind: ref_rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
2147 }
2148 };
2149 ((& $($a:lifetime)? Self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2150 $crate::def_lt_a! {
2151 [$($a)?]
2152 $crate::wrap_bin_op { trait: ($crate::std_ops_Shr)::shr, kind: rhs_rewrap(&Self), item: [$name] [$($($bound)*)?] [$($token)+] }
2153 }
2154 };
2155 (($(<$($($T:ident),+ $(,)?)?>)? $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2156 $crate::wrap_bin_op! { trait: ($crate::std_ops_Shr)::shr, kind: rhs_rewrap($Rhs), item: [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$($token)+] }
2157 };
2158 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Rhs:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2159 $crate::wrap_bin_op! { trait: ($crate::std_ops_Shr)::shr, kind: rhs_rewrap($Rhs), item: [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$($token)+] }
2160 };
2161}
2162
2163#[doc(hidden)]
2164#[macro_export]
2165macro_rules! wrap_un_op {
2166 (
2167 trait: ($($tr:tt)*)::$meth:ident,
2168 kind: simple,
2169 item: [$name:ident] [$($bound:tt)*] [$($body:tt)+]
2170 ) => {
2171 $crate::generics_parse! {
2172 $crate::wrap_un_op {
2173 generics_parse_done
2174 [
2175 trait: ($($tr)*)::$meth,
2176 kind: simple,
2177 item: [$name] [$($bound)*]
2178 ]
2179 }
2180 $($body)+
2181 }
2182 };
2183 (
2184 generics_parse_done
2185 [
2186 trait: ($($tr:tt)*)::$meth:ident,
2187 kind: simple,
2188 item: [$name:ident] [$($bound:tt)*]
2189 ]
2190 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2191 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
2192 ) => {
2193 $crate::generics_concat! {
2194 $crate::wrap_un_op {
2195 generics_concat_done
2196 [
2197 trait: ($($tr)*)::$meth,
2198 kind: simple,
2199 item: [$name] [$t0] [$([$phantom])*]
2200 ]
2201 }
2202 [$($g)*] [$($r)*] [$($w)*],
2203 [] [] [where $($bound)*]
2204 }
2205 };
2206 (
2207 generics_concat_done
2208 [
2209 trait: ($($tr:tt)*)::$meth:ident,
2210 kind: simple,
2211 item: [$name:ident] [$t0:ty] [$([$phantom:ty])*]
2212 ]
2213 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2214 ) => {
2215 $crate::as_item! {
2216 impl $($g)* $($tr)* for $name $($r)* $($w)* {
2217 type Output = Self;
2218 fn $meth(self) -> Self {
2219 $name(
2220 <$t0 as $($tr)*>::$meth(self.0)
2221 $(, <$phantom as $crate::std_default_Default>::default())*
2222 )
2223 }
2224 }
2225 }
2226 };
2227
2228 (
2229 [$a:lifetime]
2230 trait: ($($tr:tt)*)::$meth:ident,
2231 kind: simple_ref,
2232 item: [$name:ident] [$($bound:tt)*] [$($body:tt)+]
2233 ) => {
2234 $crate::generics_parse! {
2235 $crate::wrap_un_op {
2236 generics_parse_done
2237 [
2238 trait: ($($tr)*)::$meth,
2239 kind: simple_ref,
2240 item: [$a] [$name] [$($bound)*]
2241 ]
2242 }
2243 $($body)+
2244 }
2245 };
2246 (
2247 generics_parse_done
2248 [
2249 trait: ($($tr:tt)*)::$meth:ident,
2250 kind: simple_ref,
2251 item: [$a:lifetime] [$name:ident] [$($bound:tt)*]
2252 ]
2253 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2254 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
2255 ) => {
2256 $crate::generics_concat! {
2257 $crate::wrap_un_op {
2258 generics_concat_done
2259 [
2260 trait: ($($tr)*)::$meth,
2261 kind: simple_ref,
2262 item: [$a] [$name] [$t0] [$([$phantom])*]
2263 ]
2264 }
2265 [ < $a > ] [] [],
2266 [$($g)*] [$($r)*] [$($w)*],
2267 [] [] [where $($bound)*]
2268 }
2269 };
2270 (
2271 generics_concat_done
2272 [
2273 trait: ($($tr:tt)*)::$meth:ident,
2274 kind: simple_ref,
2275 item: [$a:lifetime] [$name:ident] [$t0:ty] [$([$phantom:ty])*]
2276 ]
2277 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2278 ) => {
2279 $crate::as_item! {
2280 impl $($g)* $($tr)* for & $a $name $($r)* $($w)* {
2281 type Output = $name $($r)*;
2282 fn $meth(self) -> $name $($r)* {
2283 $name(
2284 <$t0 as $($tr)*>::$meth(self.0)
2285 $(, <$phantom as $crate::std_default_Default>::default())*
2286 )
2287 }
2288 }
2289 }
2290 };
2291}
2292
2293#[macro_export]
2327macro_rules! NewtypeNeg {
2328 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2329 $crate::NewtypeNeg! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
2330 $crate::NewtypeNeg! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
2331 };
2332 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2333 $crate::wrap_un_op! { trait: ($crate::std_ops_Neg)::neg, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
2334 };
2335 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2336 $crate::def_lt_a! {
2337 [$($a)?]
2338 $crate::wrap_un_op { trait: ($crate::std_ops_Neg)::neg, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
2339 }
2340 };
2341}
2342
2343#[macro_export]
2377macro_rules! NewtypeNot {
2378 ((* $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2379 $crate::NewtypeNot! { ($(where $($bound)*)?) $vis struct $name $($token)+ }
2380 $crate::NewtypeNot! { (&self $(where $($bound)*)?) $vis struct $name $($token)+ }
2381 };
2382 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2383 $crate::wrap_un_op! { trait: ($crate::std_ops_Not)::not, kind: simple, item: [$name] [$($($bound)*)?] [$($token)+] }
2384 };
2385 ((& $($a:lifetime)? self $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2386 $crate::def_lt_a! {
2387 [$($a)?]
2388 $crate::wrap_un_op { trait: ($crate::std_ops_Not)::not, kind: simple_ref, item: [$name] [$($($bound)*)?] [$($token)+] }
2389 }
2390 };
2391}
2392
2393#[macro_export]
2407macro_rules! NewtypeDeref {
2408 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2409 $crate::generics_parse! {
2410 $crate::NewtypeDeref_impl {
2411 generics_parse_done
2412 [$name] [$($($bound)*)?]
2413 }
2414 $($token)+
2415 }
2416 };
2417}
2418
2419#[doc(hidden)]
2420#[macro_export]
2421macro_rules! NewtypeDeref_impl {
2422 (
2423 generics_parse_done
2424 [$name:ident] [$($bound:tt)*]
2425 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2426 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
2427 ) => {
2428 $crate::generics_concat! {
2429 $crate::NewtypeDeref_impl {
2430 generics_concat_done
2431 [$name] [$t0]
2432 }
2433 [$($g)*] [$($r)*] [$($w)*],
2434 [] [] [where $($bound)*]
2435 }
2436 };
2437 (
2438 generics_concat_done
2439 [$name:ident] [$t0:ty]
2440 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2441 ) => {
2442 impl $($g)* $crate::std_ops_Deref for $name $($r)* $($w)* {
2443 type Target = <$t0 as $crate::std_ops_Deref>::Target;
2444
2445 fn deref(&self) -> &Self::Target { <$t0 as $crate::std_ops_Deref>::deref(&self.0) }
2446 }
2447 };
2448}
2449
2450#[macro_export]
2464macro_rules! NewtypeDerefMut {
2465 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2466 $crate::generics_parse! {
2467 $crate::NewtypeDerefMut_impl {
2468 generics_parse_done
2469 [$name] [$($($bound)*)?]
2470 }
2471 $($token)+
2472 }
2473 };
2474}
2475
2476#[doc(hidden)]
2477#[macro_export]
2478macro_rules! NewtypeDerefMut_impl {
2479 (
2480 generics_parse_done
2481 [$name:ident] [$($bound:tt)*]
2482 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2483 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
2484 ) => {
2485 $crate::generics_concat! {
2486 $crate::NewtypeDerefMut_impl {
2487 generics_concat_done
2488 [$name] [$t0]
2489 }
2490 [$($g)*] [$($r)*] [$($w)*],
2491 [] [] [where $($bound)*]
2492 }
2493 };
2494 (
2495 generics_concat_done
2496 [$name:ident] [$t0:ty]
2497 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2498 ) => {
2499 impl $($g)* $crate::std_ops_DerefMut for $name $($r)* $($w)* {
2500 fn deref_mut(&mut self) -> &mut Self::Target { <$t0 as $crate::std_ops_DerefMut>::deref_mut(&mut self.0) }
2501 }
2502 };
2503}
2504
2505#[macro_export]
2537macro_rules! NewtypeFrom {
2538 (($($mode:tt)? $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2539 $crate::generics_parse! {
2540 $crate::NewtypeFrom_impl {
2541 generics_parse_done
2542 [$($mode)?]
2543 [$name] [$($($bound)*)?]
2544 }
2545 $($token)+
2546 }
2547 };
2548}
2549
2550#[doc(hidden)]
2551#[macro_export]
2552macro_rules! NewtypeFrom_impl {
2553 (
2554 generics_parse_done
2555 [$($mode:tt)?]
2556 [$name:ident] [$($bound:tt)*]
2557 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2558 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
2559 ) => {
2560 $crate::generics_concat! {
2561 $crate::NewtypeFrom_impl {
2562 generics_concat_done
2563 [$($mode)?]
2564 [$name] [$t0]
2565 }
2566 [$($g)*] [$($r)*] [$($w)*],
2567 [] [] [where $($bound)*]
2568 }
2569 };
2570 (
2571 generics_concat_done
2572 [wrap]
2573 [$name:ident] [$t0:ty]
2574 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2575 ) => {
2576 impl $($g)* $crate::std_convert_From<$t0> for $name $($r)* $($w)* {
2577 fn from(v: $t0) -> Self { Self(v) }
2578 }
2579 };
2580 (
2581 generics_concat_done
2582 [unwrap]
2583 [$name:ident] [$t0:ty]
2584 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2585 ) => {
2586 impl $($g)* $crate::std_convert_From<$name $($r)*> for $t0 $($w)* {
2587 fn from(v: $name $($r)*) -> Self { v.0 }
2588 }
2589 };
2590 (
2591 generics_concat_done
2592 []
2593 [$name:ident] [$t0:ty]
2594 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2595 ) => {
2596 $crate::NewtypeFrom_impl! {
2597 generics_concat_done
2598 [wrap]
2599 [$name] [$t0]
2600 [$($g)*] [$($r)*] [$($w)*]
2601 }
2602 $crate::NewtypeFrom_impl! {
2603 generics_concat_done
2604 [unwrap]
2605 [$name] [$t0]
2606 [$($g)*] [$($r)*] [$($w)*]
2607 }
2608 };
2609}
2610
2611#[macro_export]
2638macro_rules! NewtypeIndex {
2639 (($(<$($($T:ident),+ $(,)?)?>)? $Index:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2640 $crate::generics_parse! {
2641 $crate::NewtypeIndex_impl {
2642 generics_parse_done
2643 [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$Index]
2644 }
2645 $($token)+
2646 }
2647 };
2648 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Index:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2649 $crate::generics_parse! {
2650 $crate::NewtypeIndex_impl {
2651 generics_parse_done
2652 [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$Index]
2653 }
2654 $($token)+
2655 }
2656 };
2657}
2658
2659#[doc(hidden)]
2660#[macro_export]
2661macro_rules! NewtypeIndex_impl {
2662 (
2663 generics_parse_done
2664 [$name:ident] [$($lt:tt)*] [$($T:tt)*] [$($bound:tt)*] [$Index:ty]
2665 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2666 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
2667 ) => {
2668 $crate::generics_concat! {
2669 $crate::NewtypeIndex_impl {
2670 generics_concat_done
2671 [$name] [$Index] [$t0]
2672 }
2673 [$($lt)*] [] [],
2674 [$($g)*] [$($r)*] [$($w)*],
2675 [$($T)*] [] [],
2676 [] [] [where $($bound)*]
2677 }
2678 };
2679 (
2680 generics_concat_done
2681 [$name:ident] [$Index:ty] [$t0:ty]
2682 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2683 ) => {
2684 impl $($g)* $crate::std_ops_Index<$Index> for $name $($r)* $($w)* {
2685 type Output = <$t0 as $crate::std_ops_Index<$Index>>::Output;
2686
2687 fn index(&self, index: $Index) -> &Self::Output {
2688 <$t0 as $crate::std_ops_Index<$Index>>::index(&self.0, index)
2689 }
2690 }
2691 };
2692}
2693
2694#[macro_export]
2721macro_rules! NewtypeIndexMut {
2722 (($(<$($($T:ident),+ $(,)?)?>)? $Index:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2723 $crate::generics_parse! {
2724 $crate::NewtypeIndexMut_impl {
2725 generics_parse_done
2726 [$name] [] [ $($( < $($T),+ > )?)? ] [$($($bound)*)?] [$Index]
2727 }
2728 $($token)+
2729 }
2730 };
2731 ((<$($lt:lifetime),+ $(, $($T:ident),+)? $(,)?> $Index:ty $(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2732 $crate::generics_parse! {
2733 $crate::NewtypeIndexMut_impl {
2734 generics_parse_done
2735 [$name] [ < $($lt),+ > ] [ $( < $($T),+ > )? ] [$($($bound)*)?] [$Index]
2736 }
2737 $($token)+
2738 }
2739 };
2740}
2741
2742#[doc(hidden)]
2743#[macro_export]
2744macro_rules! NewtypeIndexMut_impl {
2745 (
2746 generics_parse_done
2747 [$name:ident] [$($lt:tt)*] [$($T:tt)*] [$($bound:tt)*] [$Index:ty]
2748 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2749 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
2750 ) => {
2751 $crate::generics_concat! {
2752 $crate::NewtypeIndexMut_impl {
2753 generics_concat_done
2754 [$name] [$Index] [$t0]
2755 }
2756 [$($lt)*] [] [],
2757 [$($g)*] [$($r)*] [$($w)*],
2758 [$($T)*] [] [],
2759 [] [] [where $($bound)*]
2760 }
2761 };
2762 (
2763 generics_concat_done
2764 [$name:ident] [$Index:ty] [$t0:ty]
2765 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2766 ) => {
2767 impl $($g)* $crate::std_ops_IndexMut<$Index> for $name $($r)* $($w)* {
2768 fn index_mut(&mut self, index: $Index) -> &mut Self::Output {
2769 <$t0 as $crate::std_ops_IndexMut<$Index>>::index_mut(&mut self.0, index)
2770 }
2771 }
2772 };
2773}
2774
2775#[doc(hidden)]
2776#[macro_export]
2777macro_rules! wrap_fmt {
2778 ([$tr:path] [$name:ident] [$($bound:tt)*] [$($body:tt)+]) => {
2779 $crate::generics_parse! {
2780 $crate::wrap_fmt {
2781 generics_parse_done
2782 [$tr] [$name] [$($bound)*]
2783 }
2784 $($body)+
2785 }
2786 };
2787 (
2788 generics_parse_done
2789 [$tr:path] [$name:ident] [$($bound:tt)*]
2790 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2791 ($(pub)? $t0:ty $(, $(pub)? $phantom:ty)* $(,)?);
2792 ) => {
2793 $crate::generics_concat! {
2794 $crate::wrap_fmt {
2795 generics_concat_done
2796 [$tr] [$name] [$t0]
2797 }
2798 [$($g)*] [$($r)*] [$($w)*],
2799 [] [] [where $($bound)*]
2800 }
2801 };
2802 (
2803 generics_concat_done
2804 [$tr:path] [$name:ident] [$t0:ty]
2805 [$($g:tt)*] [$($r:tt)*] [$($w:tt)*]
2806 ) => {
2807 impl $($g)* $tr for $name $($r)* $($w)* {
2808 fn fmt(&self, f: &mut $crate::std_fmt_Formatter) -> $crate::std_fmt_Result {
2809 <$t0 as $tr>::fmt(&self.0, f)
2810 }
2811 }
2812 };
2813}
2814
2815#[macro_export]
2827macro_rules! NewtypeBinary {
2828 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2829 $crate::wrap_fmt! { [$crate::std_fmt_Binary] [$name] [$($($bound)*)?] [$($token)+] }
2830 };
2831}
2832
2833#[macro_export]
2845macro_rules! NewtypeDebug {
2846 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2847 $crate::wrap_fmt! { [$crate::std_fmt_Debug] [$name] [$($($bound)*)?] [$($token)+] }
2848 };
2849}
2850
2851#[macro_export]
2863macro_rules! NewtypeDisplay {
2864 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2865 $crate::wrap_fmt! { [$crate::std_fmt_Display] [$name] [$($($bound)*)?] [$($token)+] }
2866 };
2867}
2868
2869#[macro_export]
2881macro_rules! NewtypeLowerExp {
2882 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2883 $crate::wrap_fmt! { [$crate::std_fmt_LowerExp] [$name] [$($($bound)*)?] [$($token)+] }
2884 };
2885}
2886
2887#[macro_export]
2899macro_rules! NewtypeLowerHex {
2900 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2901 $crate::wrap_fmt! { [$crate::std_fmt_LowerHex] [$name] [$($($bound)*)?] [$($token)+] }
2902 };
2903}
2904
2905#[macro_export]
2917macro_rules! NewtypeOctal {
2918 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2919 $crate::wrap_fmt! { [$crate::std_fmt_Octal] [$name] [$($($bound)*)?] [$($token)+] }
2920 };
2921}
2922
2923#[macro_export]
2935macro_rules! NewtypePointer {
2936 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2937 $crate::wrap_fmt! { [$crate::std_fmt_Pointer] [$name] [$($($bound)*)?] [$($token)+] }
2938 };
2939}
2940
2941#[macro_export]
2953macro_rules! NewtypeUpperExp {
2954 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2955 $crate::wrap_fmt! { [$crate::std_fmt_UpperExp] [$name] [$($($bound)*)?] [$($token)+] }
2956 };
2957}
2958
2959#[macro_export]
2971macro_rules! NewtypeUpperHex {
2972 (($(where $($bound:tt)*)?) $vis:vis struct $name:ident $($token:tt)+) => {
2973 $crate::wrap_fmt! { [$crate::std_fmt_UpperHex] [$name] [$($($bound)*)?] [$($token)+] }
2974 };
2975}