Skip to content

Future-prove collections::VecMap #21290

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

tbu-
Copy link
Contributor

@tbu- tbu- commented Jan 17, 2015

Since VecMap might want to have key type parameter at some point, add a key
type parameter now, so that code running today will still run when actual
generalization of the key is added.

The trait VecMapKey should really be private, but this is blocked by the fact
that you cannot export a struct, function or trait implementation with one of
the type parameters being bound by a private trait.

Since `VecMap` might want to have key type parameter at some point, add a key
type parameter now, so that code running today will still run when actual
generalization of the key is added.

The trait `VecMapKey` should really be private, but this is blocked by the fact
that you cannot export a struct, function or trait implementation with one of
the type parameters being bound by a private trait.
@rust-highfive
Copy link
Contributor

r? @nikomatsakis

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

@tbu-
Copy link
Contributor Author

tbu- commented Jan 17, 2015

Old PR: #20150

@tbu-
Copy link
Contributor Author

tbu- commented Jan 17, 2015

@gankro Have you thought about this?

@aturon We're now in alpha, could we reconsider this?

@tbu-
Copy link
Contributor Author

tbu- commented Jan 17, 2015

I added a function to the trait that is unimplementable without panic! in code outside this module, so that this only lets the std lib decide later to generalize the key of VecMaps. I'd like to add similar things to Bitv and BitvSet, after discussion of this.

@Gankra
Copy link
Contributor

Gankra commented Jan 17, 2015

I believe we have a plan to make default args involved in inference, which would mean the hack to avoid this wouldn't be necessary?

@tbu-
Copy link
Contributor Author

tbu- commented Jan 17, 2015

Depends. One thing to consider would be whether the type parameter for the key should be the first or the second.

@Diggsey
Copy link
Contributor

Diggsey commented Jan 17, 2015

It probably shouldn't be using "uint", but "usize"

@nikomatsakis
Copy link
Contributor

@gankro @tbu- perhaps we should discuss this on IRC?

/// implemented manually currently.
pub trait VecMapKey {
#[doc(hidden)]
fn to_uint(&self) -> uint;
Copy link
Contributor

Choose a reason for hiding this comment

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

clearly this should be usize

@tbu-
Copy link
Contributor Author

tbu- commented Jan 28, 2015

The conclusion of the discussion on IRC is that we might want to add this in a different way, later.

@tbu- tbu- closed this Jan 28, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants