Skip to main content

shoogah_macros/
lib.rs

1//! shoogah_macros is a helper that provides the macros for the `shoogah` crate.
2
3mod boo;
4mod cxp;
5mod hml;
6mod sin;
7mod spr;
8mod suf;
9
10#[macro_use]
11extern crate lazy_static;
12use boo::boo_impl;
13use cxp::{cxp_impl, ela_impl, elv_impl};
14use hml::hml_impl;
15use proc_macro::TokenStream;
16use sin::sin_impl;
17use spr::spr_impl;
18use suf::suf_impl;
19
20/// Define a `std::collections::HashMap` via a simple literal.
21///
22/// Refer to the `shoogah` crate documentation for details.
23#[proc_macro]
24pub fn hml(input: TokenStream) -> TokenStream {
25    hml_impl(input)
26}
27
28/// Express an if/else in a shorthand manner. This is sometimes called the
29/// *ternary* operator in other languages.
30///
31/// Refer to the `shoogah` crate documentation for details.
32#[proc_macro]
33pub fn cxp(input: TokenStream) -> TokenStream {
34    cxp_impl(input)
35}
36
37/// When the main result of an if/else is the same as the tested condition,
38/// Elvis (elv!) is here to help.
39///
40/// Refer to the `shoogah` crate documentation for details.
41#[proc_macro]
42pub fn elv(input: TokenStream) -> TokenStream {
43    elv_impl(input)
44}
45
46/// When the assigned-to variable is the condition being tested, Elvis assign
47/// (ela!) can help even more.
48///
49/// Refer to the `shoogah` crate documentation for details.
50#[proc_macro]
51pub fn ela(input: TokenStream) -> TokenStream {
52    ela_impl(input)
53}
54
55/// Incrementing or decrementing by 1.
56///
57/// Refer to the `shoogah` crate documentation for details.
58#[proc_macro]
59pub fn suf(input: TokenStream) -> TokenStream {
60    suf_impl(input)
61}
62
63/// # Collect common field values from an `Iterator`.
64///
65/// Refer to the `shoogah` crate documentation for details.
66#[proc_macro]
67pub fn spr(input: TokenStream) -> TokenStream {
68    spr_impl(input)
69}
70
71/// # String interpolation.
72///
73/// Refer to the `shoogah` crate documentation for details.
74#[proc_macro]
75pub fn sin(input: TokenStream) -> TokenStream {
76    sin_impl(input)
77}
78
79/// # Boolean coercion
80///
81/// Refer to the `shoogah` crate documentation for details.
82#[proc_macro]
83pub fn boo(input: TokenStream) -> TokenStream {
84    boo_impl(input)
85}