Skip to content

TRPL: type aliases and unsized types #24675

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 1 commit into from
Apr 23, 2015

Conversation

steveklabnik
Copy link
Member

Two more chapters of TRPL. The type one is pretty straightforward, but I wasn't really sure what to put for unsized types. I just explained the very basics, and the special bounds syntax. Thoughts on what else should go here?

r? @alexcrichton

}
```

This compiles without error. `Num` types are the same as `i32`s, in every way.
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this means "values of type Num"? It's a bit confusing as is.

Copy link
Member Author

Choose a reason for hiding this comment

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

noted, and updated

@killercup
Copy link
Member

Nicely written.

Could you perhaps add a more motivating example for type? Something like type Contacts = Arc< LinkedList<Contact<Person, Address>>> might show the usefulness of renaming types (to shorter names) a bit better.

@steveklabnik
Copy link
Member Author

@killercup ahh yes, good call 👍

@alexcrichton
Copy link
Member

The type section could also be expanded with generics, for example:

type Result<T> = result::Result<T, ConcreteError>;

(e.g. io::Result)

}
```

This `?` means that this bound is special: it lets us match more kinds, not
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this could mention something like "?Sized is normally read as 'maybe not sized'"? I guess just getting the phrase "maybe unsized" may help a bit.

@alexcrichton
Copy link
Member

I think the unsized type section may also want some motivating examples as well. For example it enables impl Trait for str or impl Trait for [T] which can be quite useful in practice. Other examples are Box<[T]> and Box<str> but those aren't so common and can probably be omitted for now.

@steveklabnik
Copy link
Member Author

Updated!

@alexcrichton
Copy link
Member

@bors: r+ defdc44 rollup

Yay!

@bors
Copy link
Collaborator

bors commented Apr 22, 2015

🙀 defdc4418a2da483f8adeb2928c1ba1cddc5f7de is not a valid commit SHA. Please try again with 7799a79.

@alexcrichton
Copy link
Member

@bors: r+ defdc44 rollup

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

Two more chapters of TRPL. The `type` one is pretty straightforward, but I wasn't really sure what to put for unsized types. I just explained the very basics, and the special bounds syntax. Thoughts on what else should go here?

r? @alexcrichton
@bors bors merged commit defdc44 into rust-lang:master Apr 23, 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.

5 participants