#macro #bad #create #world #ever #dis #worst

funkjon

One of the worst macros this world has ever been (dis)graced with

3 stable releases

1.0.2 Apr 12, 2024
1.0.1 Jan 24, 2024
1.0.0 Jan 19, 2024

#745 in Rust patterns

Download history 3/week @ 2024-01-20 10/week @ 2024-02-17 16/week @ 2024-02-24 2/week @ 2024-03-02 7/week @ 2024-03-09 1/week @ 2024-03-16 26/week @ 2024-03-30 63/week @ 2024-04-06 116/week @ 2024-04-13 1/week @ 2024-04-20

180 downloads per month

MIT license

5KB
55 lines

Funkjon - a bad macro

With funkjon, you too can create your very own function.

Usage:

funkjon!(greet :: name {
    println!("Hello, {name}.");
} as (String) -> Unit);

greet("David".to_string());

By the way, Unit is the return type. It is equivalent to (). You can change it by just putting something other than Unit next to the right arrow (->).

Usage with generics:

funkjon!(greet ::<T: std::fmt::Display>:: name {
    println!("Hello, {name}.");
} as (T) -> Unit);

greet("David");

Or with a where clause

funkjon!(greet ::<T>:: name {
    println!("Hello, {name}.");
} as (T) -> Unit
    where T: std::fmt::Display,
);

greet("David");

No runtime deps