Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow free type of partition subdivisions #33

Open
milibopp opened this issue Jan 10, 2015 · 3 comments
Open

Allow free type of partition subdivisions #33

milibopp opened this issue Jan 10, 2015 · 3 comments

Comments

@milibopp
Copy link
Owner

Consider the Partition trait:

pub trait Partition<T>: Sized {
    fn subdivide(&self) -> Vec<Self>;
    /* ... */
}

One could imagine impls of Partition that subdivide into another implementation of Partition. Currently this would have to be worked around by wrapping such partitions in an enum that comprises both. However the following does not compile:

pub trait Partition<T>: Sized {
    type Subdivision: Partition<T>;
    fn subdivide(&self) -> Vec<Subdivision>;
    /* ... */
}

For this to work rust-lang/rust#20551 needs to be fixed (only if such recursion is intended to be allowed, of course).

@milibopp
Copy link
Owner Author

milibopp commented Feb 4, 2015

With the reformed partition traits the above of course applies to Subdivide instead of Partition.

@milibopp
Copy link
Owner Author

This should be possible now, as the aforementioned compiler bug has been fixed.

@milibopp
Copy link
Owner Author

Given rust-lang/rust#22446, this is not particularly useful to implement currently. The split between Subdivide and Partition is a problem as one has to provide the information that a subdivided part is a partition in a where clause, and this information does not propagate properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant