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

Add documentation on trait objects. #22106

Merged
merged 1 commit into from
Feb 10, 2015

Conversation

steveklabnik
Copy link
Member

I started to write up some docs on this, and then realized I was just repeating http://huonw.github.io/blog/2015/01/peeking-inside-trait-objects/ but worse. @huonw previously said that we can use this content if we wanted, so I made some tweaks and integrated it into the book.

Fixes #21707

@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@huonw
Copy link
Member

huonw commented Feb 9, 2015

❤️

(It's probably better if I don't review, given I wrote a lot of it.)

@steveklabnik
Copy link
Member Author

Hehe, yeah, I thought about it, and decided to let @rust-highfive do its thing. The edits are actually very small.

binary, one for each type.

Furthermore, compilers aren’t perfect and may “optimise” code to become slower.
For example, functions inlined too eagerly will bloating the instruction cache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will end up bloating?

@alexcrichton
Copy link
Member

Nice! A few small nits and otherwise r=me

@steveklabnik
Copy link
Member Author

@bors: r=alexcrichton dbccd70 rollup


However, the common case is that it is more efficient to use static dispatch,
and one can always have a thin statically-dispatched wrapper function that does
a dynamic, but not vice versa, meaning static calls are more flexible. The
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/does a dynamic/does a dynamic call/?

Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 10, 2015
…lexcrichton

I started to write up some docs on this, and then realized I was just repeating http://huonw.github.io/blog/2015/01/peeking-inside-trait-objects/ but worse. @huonw previously said that we can use this content if we wanted, so I made some tweaks and integrated it into the book.

Fixes rust-lang#21707
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Feb 10, 2015
I started to write up some docs on this, and then realized I was just repeating http://huonw.github.io/blog/2015/01/peeking-inside-trait-objects/ but worse. @huonw previously said that we can use this content if we wanted, so I made some tweaks and integrated it into the book.

Fixes rust-lang#21707
@bors bors merged commit dbccd70 into rust-lang:master Feb 10, 2015
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

Successfully merging this pull request may close these issues.

Document trait objects in the book
6 participants