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

Generic Functions enable static dispatch: how? #360

Open
jtwilliamss opened this issue Mar 2, 2021 · 2 comments
Open

Generic Functions enable static dispatch: how? #360

jtwilliamss opened this issue Mar 2, 2021 · 2 comments

Comments

@jtwilliamss
Copy link

jtwilliamss commented Mar 2, 2021

I understand Generic Functions enable

  1. static dispatch (https://tourofrust.com/84_en.html) instead of / over
  2. dynamic dispatch (https://tourofrust.com/81_en.html).

What I do not understand is how.

Specifically: how does the compiler better know the "real type" (of the NoiseMaker trait) with (1.) over (2.)?

[Is this "how does Rust work?" question outside the scope of an issue submission for this project?]

ps. tour_of_rust is my favorite "learning as a Rust newbie" I've found thus far. Thanks so much for putting this together.

@jtwilliamss
Copy link
Author

My potentially-overly-summarized conclusion (see reddit.com discussion above for more details): dyn specifically disables static dispatch.

In any case, closing this issue.

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

1 participant