omg i learned about how to write macros in #rustlang the other day and i feel so powerful
Rust code Show more
@wowaname i love it! one way i put it the other day is that it's like the convenience of Python with the power of C
literally one of my favorite things about it is that it's a low-level system programming language like C but has a lot of the sort of neat standard library functions that Python has so it's not a pain in the ass to write code in
@wowaname just about the only thing that's a pain to deal with is problems with borrowing and lifetimes, but honestly i bring a lot of the lifetime issues on myself by trying to make things too generic (usually before even fully implementing them for the specific case i need) lol
Rust code Show more
i just wrote one that's a tiny DSL
macro_rules! impl_state_transitions {(
$state_machine:ident.$state_field:ident {
$( $state1:ident => $state2:ident ),*
}) => {
$(
impl From<$state_machine<$state1>> for $state_machine<$state2> {
fn from(m: $state_machine<$state1>) -> $state_machine<$state2> {
$state_machine { $state_field: $state2 }
}
}
)*
}
}