Post

Can someone explain to me why the PhantomData<fn() -> T> behavior cannot be the default implied behavior for unused types in Rust? (aka: pretend T is not stored on the type ... because it isn't). PhantomData comes up constantly for me in safe code and it feels SO clunky to me.

In a language where you can define some Foo trait for behaviors that don't take "self" as a parameter (ex: Foo::do_thing()), it feels pretty wild to me that being generic on that behavior requires anything more than specifying that you want MyType<T: Foo>.

0 reposts4 likes