# [−][src]Macro typenum::op

    macro_rules! op {
        ($($tail:tt)*) => { ... };
    }

Convenient type operations.

Any types representing values must be able to be expressed as `ident`s. That means they need to be in scope.

For example, `P5` is okay, but `typenum::P5` is not.

You may combine operators arbitrarily, although doing so excessively may require raising the recursion limit.

# Example

    #![recursion_limit="128"]
    #[macro_use] extern crate typenum;
    use typenum::consts::*;

    fn main() {
        assert_type!(
            op!(min((P1 - P2) * (N3 + N7), P5 * (P3 + P4)) == P10)
        );
    }

Operators are evaluated based on the operator precedence outlined here.

The full list of supported operators and functions is as follows:

`*`, `/`, `%`, `+`, `-`, `<<`, `>>`, `&`, `^`, `|`, `==`, `!=`, `<=`, `>=`, `<`, `>`, `cmp`, `sqr`, `abs`, `cube`, `pow`, `min`, `max`

They all expand to type aliases defined in the `operator_aliases` module. Here is an expanded list, including examples:

Operator `*`. Expands to `Prod`.

    assert_type_eq!(op!(P2 * P3), P6);

Operator `/`. Expands to `Quot`.

    assert_type_eq!(op!(P6 / P2), P3);

Operator `%`. Expands to `Mod`.

    assert_type_eq!(op!(P5 % P3), P2);

Operator `+`. Expands to `Sum`.

    assert_type_eq!(op!(P2 + P3), P5);

Operator `-`. Expands to `Diff`.

    assert_type_eq!(op!(P2 - P3), N1);

Operator `<<`. Expands to `Shleft`.

    assert_type_eq!(op!(U1 << U5), U32);

Operator `>>`. Expands to `Shright`.

    assert_type_eq!(op!(U32 >> U5), U1);

Operator `&`. Expands to `And`.

    assert_type_eq!(op!(U5 & U3), U1);

Operator `^`. Expands to `Xor`.

    assert_type_eq!(op!(U5 ^ U3), U6);

Operator `|`. Expands to `Or`.

    assert_type_eq!(op!(U5 | U3), U7);

Operator `==`. Expands to `Eq`.

    assert_type_eq!(op!(P5 == P3 + P2), True);

Operator `!=`. Expands to `NotEq`.

    assert_type_eq!(op!(P5 != P3 + P2), False);

Operator `<=`. Expands to `LeEq`.

    assert_type_eq!(op!(P6 <= P3 + P2), False);

Operator `>=`. Expands to `GrEq`.

    assert_type_eq!(op!(P6 >= P3 + P2), True);

Operator `<`. Expands to `Le`.

    assert_type_eq!(op!(P4 < P3 + P2), True);

Operator `>`. Expands to `Gr`.

    assert_type_eq!(op!(P5 < P3 + P2), False);

Operator `cmp`. Expands to `Compare`.

    assert_type_eq!(op!(cmp(P2, P3)), Less);

Operator `sqr`. Expands to `Square`.

    assert_type_eq!(op!(sqr(P2)), P4);

Operator `abs`. Expands to `AbsVal`.

    assert_type_eq!(op!(abs(N2)), P2);

Operator `cube`. Expands to `Cube`.

    assert_type_eq!(op!(cube(P2)), P8);

Operator `pow`. Expands to `Exp`.

    assert_type_eq!(op!(pow(P2, P3)), P8);

Operator `min`. Expands to `Minimum`.

    assert_type_eq!(op!(min(P2, P3)), P2);

Operator `max`. Expands to `Maximum`.

    assert_type_eq!(op!(max(P2, P3)), P3);

# 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`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)