External Publication
Visit Post

Yet another half-baked idea for working around the orphan rule

Rust Internals [Unofficial] March 31, 2026
Source

burakumin:

fn main() {
    let path = get_path(); // Assume this is a unix_path::Path
    let path = path as unix_path::Path\WithArg; // no-op
    rustix::fs::open(path, O_RDONLY, M_IGNORED);
}

I suspect that requiring path as unix_path::Path\WithArg still constitutes "ceremony" from your perspective

Yeah. Don't get me wrong, this would be an improvement over what I have to write now: I wouldn't have to repeat a chain of non-obvious conversions at every callsite! But it is still obscuring the actual logic at this level with conversions, and it's still something that has to be done at every callsite.

But if you could make this work, that would be good enough for me

// once in the crate
facet WithArg for unix_path::Path;
impl rustix::path::Arg for Path\WithArg { /* ... */ }

// anywhere the `facet WithArg` declaration is visible
fn main() {
    rustix::fs::open(get_path().into(), O_RDONLY, M_IGNORED);
}

It's still something I have to do at each callsite, but it's much shorter and -- because it doesn't involve naming Path\WithArg -- much less distracting from the actual logic.

Discussion in the ATmosphere

Loading comments...