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

"Type Aliases" improvements #1515

Open
djmitche opened this issue Nov 29, 2023 · 1 comment
Open

"Type Aliases" improvements #1515

djmitche opened this issue Nov 29, 2023 · 1 comment
Assignees

Comments

@djmitche
Copy link
Collaborator

From my notes:

  • "9.5. Type Aliases: The example shows how to declare, but on how it looks in
    practice is not clear enough (there is a use of one type alias but it's
    hidden in a complex type). Ideally I would add some function signatures or
    custom structs that showcase the cleanliness of this." (@deavid)

@deavid I've lost the context for this comment. Now that v2 has landed, do you remember enough to make a PR for this?

@djmitche djmitche self-assigned this Nov 29, 2023
@djmitche djmitche assigned deavid and unassigned djmitche Dec 13, 2023
@deavid
Copy link
Collaborator

deavid commented Dec 13, 2023

https://google.github.io/comprehensive-rust/user-defined-types/aliases.html

The problem is that the only usage is: RwLock<Vec<Arc<RefCell<Item>>>>

And it is hard to spot "Item" in there.

This is one of these instances where a mentor can explain things better but anyone trying to follow it on their own will be puzzled.

Adding a function where we can see the usefulness would be interesting, for example:

fn inventory_into_vec(inv: PlayerInventory) -> Vec<Item> {
   // ...
}

Just an example. Could be simpler. But having a practical use where we can showcase the usefulness would be interesting. Although to be fair we don't use type aliases often, or at least I don't.

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