logoalt Hacker News

Quitschquat • yesterday at 3:41 PM • 1 reply • view on HN

What's the orphan rule?


Replies

estebank • yesterday at 4:01 PM

Rust doesn't let you write an impl a trait that wasn't declared in your crate for a type that wasn't declared in your crate. At least one of the two needs to be locally declared. This makes splitting projects into multiple crates harder than it could be, but on the other hand it makes the crates ecosystem less brittle than it otherwise would be.

Some people propose relaxing this rule for "workspaces" (local projects with multiple crates that are not published individually). I haven't researched whether that would be technically feasible.

➕ show 2 replies