# Macro synstructure::test_derive [−] [src]

    macro_rules! test_derive {
        ($name:path { $($i:tt)* } expands to { $($o:tt)* }) => { ... };
        ($name:path { $($i:tt)* } expands to { $($o:tt)* } no_build) => { ... };
    }

Run a test on a custom derive. This macro expands both the original struct and the expansion to ensure that they compile correctly, and confirms that feeding the original struct into the named derive will produce the written output.

You can add `no_build` to the end of the macro invocation to disable checking that the written code compiles. This is useful in contexts where the procedural macro cannot depend on the crate where it is used during tests.

# Usage

ⓘThis example is not tested

    test_derive!{
        super::derive_interesting {
            struct A {
                a: i32,
                b: i32,
            }
        }
        expands to {
            impl ::Interesting for A {
                fn is_interesting(&self) -> bool {
                    match *self {
                        A { a: ref __binding_0, b: ref __binding_1, } => {
                            false ||
                                ::Interesting::is_interesting(__binding_0) ||
                                ::Interesting::is_interesting(__binding_1)
                        }
                    }
                }
            }
        }
    }

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)