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 upa way to compose functions #28226
Comments
This comment has been minimized.
This comment has been minimized.
|
This is a question for the libs team, I'm not 100% what granularity of change necessitates an RFC in the libs world. cc @rust-lang/libs |
This comment has been minimized.
This comment has been minimized.
|
My suggestion would be to post this as a Pre-RFC on https://internals.rust-lang.org/ so that you can solicit feedback. It is a brand new API though, so I would expect something like this to ultimately require an RFC though. |
steveklabnik
added
the
A-libs
label
Sep 4, 2015
This comment has been minimized.
This comment has been minimized.
|
Dumb question: what prevents (Or in other words, what would adding |
This comment has been minimized.
This comment has been minimized.
|
This is a good question. The main here was just to demonstrate that the direct thing works. In reality, you want something like: struct Mapped<I, F> {
iter: I,
func: F
}
struct Compose<F, G>(F, G);
fn map<I, T, U, F, F2, U2>(m: Mapped<I, F>, func: F2) -> Mapped<I, Compose<F, F2>>
where I: Iterator<Item=T>,
F: Fn(T) -> U,
F2: Fn(U) -> U2 {
Mapped { iter: m.iter, func: Compose(m.func, func) }
}You could do this by continuing to return This is useful for data flow programming systems (similar to spark) where you might want to build up a large computation description, but not run it right away (in fact, you might only run part of it on a given node). |
This comment has been minimized.
This comment has been minimized.
|
added a discussion here: https://internals.rust-lang.org/t/function-composition-in-the-standard-library/2615 Not sure where we should discuss. |
This comment has been minimized.
This comment has been minimized.
|
I see, so an unboxed |
This comment has been minimized.
This comment has been minimized.
|
Triage: small API additions just need a PR; larger ones need an RFC. Please pursue one of those two avenues, thanks! |
johnynek commentedSep 4, 2015
Here is a way (I was pointed to this by mbrubeck on the rust IRC channel) to compose two functions.
This seems like something it would be worth adding to the standard library.
Should I just open a pull request or is there another process for this kind of proposal?