A vision for portability in Rust

It's not only resources, I think, but also "behavior". For example, I'd bundle the "panic behavior" in there.

And going back to how panic works, it seems that letting the final binary decides which trait implementation goes has some benefits, such as ensuring that a single trait implementation goes in.

It's a bit like the binary would instantiate:

struct Runtime<
    A: Allocator,
    F: FileSystem,
    O: OperatingSystem<FileSystem = F>,
    P: Panic,
    T: Thread<OperatingSystem = O>,
>();

impl<...> Runtime<...> {
    fn start() { ... }
}

plugging in the implementation of each trait as per the user selection.

3 Likes