is there a particular reason why this is not allowed?

fn my_function(){ ..... } impl MyTrait for my_function{ } 

i feel like if i can implement for a generic fn i should be also able for an exact one

i know i can easily cirumvent this by simply making a trait with both fn and use that but in my usecase it was just way cleaner to be able to do this where you would write the first function and have the second made through macros

fn some_fn(m:SomeEnum){ match m{ SomeEnum::A=>a() SomeEnum::B=>b() SomeEnum::C=>c() } impl WithMetaData for somefn{ fn get_metadata()->Meta{ let mut meta=Meta::new(); meta.insert(SomeEnum::A,<a as WithMetaData>::get_metadata()); meta.insert(SomeEnum::B,<b as WithMetaData>::get_metadata()); meta.insert(SomeEnum::C,<c as WithMetaData>::get_metadata()); } } 

1 post - 1 participant

Read full topic