Auto implementing foreign trait for all private trait implementors

⚓ Rust    📅 2026-01-03    👤 surdeus    👁️ 4      

surdeus

I've got a quick question. Why isn't

impl<T:PrivateTrait> TraitFromStdLib for T 

allowed. I get why it isn't allowed for traits beyond your control. But there really isn't any weird edge case behaviour with allowing this (specifically for traits private within a crate) is there?

I couldn't come up with an counter example (and there shouldn't be, as all implementors of PrivateTrait are local to the crate and thus respect the rules of implementing foreign traits). It would be nice if Rust supported this natively, without have to write a lot of auto impl macros.

5 posts - 4 participants

Read full topic

🏷️ Rust_feed