Macro bigerror::from_report

source ·
macro_rules! from_report {
    ({ impl From<$from:path as ToReport<_> $(as $context:path)*> $($tail:tt)* }) => { ... };
    ({ impl From<$from:path as ToReport<_>> $($tail:tt)* }) => { ... };
    ({ impl From<Report<$from:path>> $($tail:tt)* }) => { ... };
    ({ impl From<$from:path $(as $context:path)*> $($tail:tt)*  }) => { ... };
    (
    @t[$($t:path $(as $t_context:path)*,)*]
    @report_t[$($report_t:path)*]
    @to_report[$($to_report:path $(as $to_context:path)*,)*]
    impl From<Report<$from:path>> $($tail:tt)*) => { ... };
    (
    @t[$($t:path $(as $t_context:path)*,)*]
    @report_t[$($report_t:path)*]
    @to_report[$($to_report:path $(as $to_context:path)*,)*]
    impl From<$from:path as ToReport<_> $(as $context:path)*> $($tail:tt)*) => { ... };
    (
    @t[$($t:path $(as $t_context:path)*,)*]
    @report_t[$($report_t:path)*]
    @to_report[$($to_report:path $(as $to_context:path)*,)*]
    impl From<$from:path as ToReport<_>> $($tail:tt)*) => { ... };
    (
    @t[$($t:path $(as $t_context:path)*,)*]
    @report_t[$($report_t:path)*]
    @to_report[$($to_report:path $(as $to_context:path)*,)*]
    impl From<$from:path $(as $context:path)*> $($tail:tt)*) => { ... };
    (
    @t[$($t:path $(as $t_context:path)*,)*]
    @report_t[$($report_t:path)*]
    @to_report[$($to_report:path $(as $to_context:path)*,)*]
    for $for:ident::$variant:ident($inner:path)) => { ... };
    (impl From<Report<$from:path>> for $for:ident::$variant:ident) => { ... };
    (impl From<$from:path as ToReport<$context:path>> for $for:ident::$variant:ident) => { ... };
    (impl From<$from:path $(as $context:path)*> for $for:ident::$variant:ident) => { ... };
}
Expand description

USAGE:

  • impl From<SomeError as ToReport<_> $(as $context:path)*> for OurError::Report(OurReportError)
  • Implements From<E> where E: ToReport<_> for errors that implement ToReport
  • impl From<Report>> for OurError::Report(TransactionError)
  • Implements From<Report<SomeError>> for Report<OurReportError>
  • impl From<SomeError $(as $context:path)*> for OurError::Report(TransactionError)
  • Implements From<SomeError> for Report<OurReportError>
  • Used to cast an error to OurReportError, can use as to do multiple ::from conversion: impl From<SomeError as MiddleError> does a concrete implementation of the impl below where E is SomeError: impl From<E> for OurError where E: Into<MiddleError> {}