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

Suggestion to rewrite variance in fuction arguments explanation #394

Open
andronov-alexey opened this issue Jan 8, 2023 · 2 comments
Open

Comments

@andronov-alexey
Copy link

I have a hard time trying to understand variance in function arguments in the following chapter:

However, the same logic does not apply to arguments. Consider trying to satisfy:

fn handle_animal(Animal);

with:

fn handle_animal(Cat);

The first function can accept Dogs, but the second function absolutely can't.
Covariance doesn't work here. But if we flip it around, it actually does
work! If we need a function that can handle Cats, a function that can handle any
Animal will surely work fine. Or to relate it back to real Rust: if we need a
function that can handle anything that lives for at least 'long, it's perfectly
fine for it to be able to handle anything that lives for at least 'short.

The most confusing thing is what does it mean to "satisfy one function with the other"?

I'd suggest to rewrite this paragraph

@sgasse
Copy link

sgasse commented Jan 27, 2023

I read the example today as well and through about fleshing it out a little bit but I do not want to get into anyone's way. @andronov-alexey do you want to work on this and just wait for a thumbs-up from a maintainer, or did you just want to bring it up?

@andronov-alexey
Copy link
Author

@sgasse I just wanted to bring it up and I'd really appreciate if someone rewrote it :)

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