struct Disk<T: Read + Seek + Write> {
handle: T,
}
struct Partition<T: Read + Seek + Write> {
disk: Disk<T>,
}
struct File<T: Read + Seek + Write> {
partition: Partition<T>,
}
At the point of struct Partition
, it is no longer interesting what Disk
s trait-bounds are. Through the language design, it is not possible to create a Disk
with a handle what does not have Read + Seek + Write
. Through this example is very simple, types might become extremely complex if they have multiple members with traits.
What I want is:
struct Disk<T: Read + Seek + Write> {
handle: T,
}
type ExDisk = FIXME;
struct Partition {
disk: ExDisk,
}
struct File {
partition: Partition,
}