Macro winsafe::seq_ids

source ·
macro_rules! seq_ids {
    () => { ... };
    ($val:expr,) => { ... };
    (
		$( #[$comment:meta] )*
		$name:ident = $val:expr;
		$( $others:tt )*
	) => { ... };
    (
		$next_val:expr,
		$( #[$comment:meta] )*
		$name:ident = $val:expr;
		$( $others:tt )*
	) => { ... };
    (
		$next_val:expr,
		$( #[$comment:meta] )*
		$name:ident
		$( $others:tt )*
	) => { ... };
}
Expand description

Generates sequential u16 constants starting from the given value.

This macro is useful to generate constants for loaded resources, like menus or dialog windows.

Each constant also supports individual documentation.

§Examples

use winsafe::seq_ids;

seq_ids! {
    MNU_FILE = 3000;
    MNU_FILE_OPEN
    MNU_FILE_SAVE
    /// This menu closes the application.
    MNU_FILE_CLOSE
}

The code above will generate the following:

pub const MNU_FILE: u16 = 3000;
pub const MNU_FILE_OPEN: u16 = 3001;
pub const MNU_FILE_SAVE: u16 = 3002;
/// This menu closes the application.
pub const MNU_FILE_CLOSE: u16 = 3003;