     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86

    //!  Mynewt Macros for Rust. Note that macros defined locally should be called with `$crate::`, like `$crate::parse`.
    //!  This works with Rust compiler versions 1.30 and later.  See https://doc.rust-lang.org/stable/edition-guide/rust-2018/macros/macro-changes.html
    //!  To see the expanded macros: `cargo rustc -- -Z unstable-options --pretty expanded`

    ///////////////////////////////////////////////////////////////////////////////
    //  Utility Macros

    ///  Return a const struct that has all fields set to 0. Used for initialising static mutable structs like `os_task`.
    ///  `fill_zero!(os_task)` expands to
    ///  ```
    /// unsafe {
    ///	::core::mem::transmute::
    ///	<
    ///	  [
    ///		u8;
    ///		::core::mem::size_of::<os_task>()
    ///	  ],
    ///	  os_task
    ///	>
    ///	(
    ///	  [
    ///		0;
    ///		::core::mem::size_of::<os_task>()
    ///	  ]
    ///	)
    /// }
    ///  ```
    #[macro_export]
    macro_rules! fill_zero {
      ($type:ident) => {
        unsafe {
            ::core::mem::transmute::
            <
            [
                u8;
                ::core::mem::size_of::<$type>()
            ],
            $type
            >
            (
            [
                0;
                ::core::mem::size_of::<$type>()
            ]
            )
        }
      };
    }

    ///  Macro that takes an identifier and returns a `[u8]` containing the identifier, terminated by 0.
    ///  Used to convert an identifier to a C null-terminated string.
    #[macro_export]
    macro_rules! stringify_null {
      ($key:ident) => {  //  If $key is identifier...
        concat!(
          stringify!($key),
          "\0"
        )
      };
    }

    ///  Macro to dump all tokens received as a literal string, e.g.
    ///  `d!(a b c)` returns `"a b c"`
    #[macro_export]
    macro_rules! d {
      //  This rule matches zero or more tokens.
      ($($token:tt)*) => {
        //  For all matched tokens, convert into a string.
        stringify!($($token)*)
      };
    }

    ///  Macro to display the token being parsed and the remaining tokens
    #[macro_export]
    macro_rules! nx {
      (($($current:tt)*), ($($next:tt)*), ($($rest:tt)*)) => {
        concat!(
          " >> ",
          stringify!($($current)*),
          " >> ",
          stringify!($($next)*),
          " >> ",
          stringify!($($rest)*)
        );
      };
    }

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