Skip to content

Write up default methods for the tutorial. #11270

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

Merged
merged 5 commits into from
Jan 6, 2014
Merged

Conversation

lkuper
Copy link
Contributor

@lkuper lkuper commented Jan 2, 2014

I've been wanting to explain default methods in the tutorial for ages. While I was at it I tried to clarify some other parts of the traits section. I'm sure this could be improved further; suggestions welcome.

@@ -2094,12 +2095,13 @@ fn head<T: Clone>(v: &[T]) -> T {
}
~~~~

This says that we can call `head` on any type `T`
as long as that type implements the `Clone` trait.
The bounded type parameter `T: Clone` says that `head` is polymorphic
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe say "can be called with any type T"? I think we want to avoid PL jargon in the tutorial.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pcwalton OK, I changed this and a couple other minor things.

@adrientetar
Copy link
Contributor

r? @pcwalton

types to be exactly as it is for `int`, above:

~~~~
impl Printable for f32 {
Copy link
Contributor

Choose a reason for hiding this comment

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

# trait Printable { fn print(&self); } is missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ugh, thanks. Fixed.

bors added a commit that referenced this pull request Jan 6, 2014
I've been wanting to explain default methods in the tutorial for ages.  While I was at it I tried to clarify some other parts of the traits section.  I'm sure this could be improved further; suggestions welcome.
@bors bors closed this Jan 6, 2014
@bors bors merged commit 8224816 into rust-lang:master Jan 6, 2014
@lkuper lkuper deleted the trait-docs branch January 6, 2014 18:34
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.

5 participants