id

Macro id 

Source
id!() { /* proc-macro */ }
Expand description

Returns an Id validated at compile time.

§Examples

Instantiate a valid Id at compile time:

use id_newtype::id;

let _my_id: Id = id!("valid_id"); // Ok!

If the ID is invalid, a compilation error is produced:

use id_newtype::id;

let _my_id: Id = id!("-invalid_id"); // Compile error
//               ^^^^^^^^^^^^^^^^^^
// error: "-invalid_id" is not a valid `Id`.
//        `Id`s must begin with a letter or underscore, and contain only letters, numbers, or underscores.