#auto #ergonomics #macro #function #proof-of-concept #slight #anti-pattern

macro auto_into

a rust macro that provides (slight) ergonomics for writing functions

1 unstable release

0.1.0 Dec 1, 2022

#5 in #proof-of-concept

MIT license

6KB
118 lines

auto_into

this macro was born out of this internals.rust discusssion.

i've come around to thinking that this is an anti-pattern, i don't recommend you actually use this create. but developing it was cool and it works as a proof-of-concept if this discussion is ever brought up again.

Usage

here's the code example

use auto_into::auto_into;

#[auto_into]
fn takes_whatever(#[into] _: String) { }

fn main() {
	takes_whatever("lorem"); // &str
	takes_whatever(std::borrow::Cow::Borrowed("ipsum")); // moo
	takes_whatever(format!("{} sit", "dolor")); // String
	takes_whatever('a'); // char
}

Dependencies

~1.5MB
~37K SLoC