Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upLattice specialization could allow methods to be removed from macro #1
Comments
withoutboats
added
the
enhancement
label
Sep 19, 2016
This comment has been minimized.
This comment has been minimized.
|
Writing so I will remember it when I can implement this: This does not require lattice specialization! It just requires further use of the trait MaybeGet {
fn attach_get<R: Router>(router: &mut R);
}
// By default, attach nothing
impl<T> MaybeGet for T {
default fn attach_get<R: Router>(_: &mut R) { }
}
impl<T: Get> MaybeGet for T {
fn attach_get<R: Router>(router: &mut R) {
router.attach_get(...)
}
} |
This comment has been minimized.
This comment has been minimized.
|
Implemented this for resource methods, relation methods in the next day or two, then I'll close this issue |
This comment has been minimized.
This comment has been minimized.
|
Now implemented |
withoutboats
closed this
Nov 23, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
withoutboats commentedSep 19, 2016
•
edited
The current syntax of the
routes!macro requires the author to specify every method each resource supports, e.g.:The user then additionally provides an impl of the trait associated with each method for
Photo.This is redundant work, but its necessary for the macro to be expanded in a way which attaches each method for that resource (see the
methods!macro in the current version of the source).With lattice specialization, we could instead provide a single entry point, specialized for all of the combinations of methods that could be supported. This would be a lot of boilerplate for cargonauts, but it would save much more boilerplate for cargonauts users. For example:
This requires lattice specialization because the method traits do not form a specialization order between them.