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

Can this solution apply for function? #31

Closed
gianghad opened this issue Aug 18, 2022 · 2 comments
Closed

Can this solution apply for function? #31

gianghad opened this issue Aug 18, 2022 · 2 comments

Comments

@gianghad
Copy link

gianghad commented Aug 18, 2022

When I use pipe in another language I don't want it to compile immediately, just want to create a new function. Ex:

fn add1(a: usize) -> usize {
    a + 1
}

fn multiple(a: usize) -> usize {
    a * 2
}

Now I want a new function that will add1 first then multiple. Is there any way we can do it like this
let newFunc = add1.pipe(multiple)

@KSXGitHub
Copy link
Owner

Do you have any problem with closure?

let new_func = |a: usize| a.pipe(add1).pipe(multiple);

@gianghad
Copy link
Author

Hey, that's a good one. I come from another language with a different approach. This is cool. Thanks

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

No branches or pull requests

2 participants