-
Notifications
You must be signed in to change notification settings - Fork 13.4k
add #[experimental] as_string/as_vec functions #16713
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
Conversation
cc @pcwalton |
I think that the issue referred to in #14549 is a more wide-reaching issue than just I know that @aturon has been working on solutions to this problem with multidispatch and some other RFCs he's got cooking, and I'm curious what his opinion on this is here. |
There's already #12135 about Equiv in general. The |
This is also useful outside of the context of equality / ordering, as it applies to any generic types exposing an |
We can use the same trick for viewing a This isn't necessarily general enough to work with all data types, e.g. a particularly fancy rope/fingertree-based |
I think this would be worthwhile to have as an experiment, thats what |
I think that we should wait for @aturon's RFC. I'll make sure he's aware of and considers this alternative. |
This is a clever idea, and may be worth providing even if we deal with For reference, the current proposal for dealing with // map: HashMap<String, T>
map.find("some static string") rather than map.find("some static string".as_string()) |
FWIW, I'm currently fighting with a case where I have |
Yes, it's a general solution to a class of problems with |
Dear god what a hack. And I mean that in the best possible way. I do want to see if we can do something more general than this, but it's interesting to know that it's an option. |
@Florob I don't think this would help in that case, at least not directly. Your key type is the tuple |
@nikomatsakis: Well, that's why I marked it |
This provides a way to pass `&[T]` to functions taking `&U` where `U` is a `Vec<T>`. It can be seen as an alternative to the `Equiv` trait, as it handles all of the common cases well, without requiring a new trait and new equiv methods. Methods like `find_with` on TreeMap taking a closure with an equivalent `Ord` implementation are still useful. Closes #14549
Closing due to inactivity, but feel free to reopen with a rebase! |
This provides a way to pass
&[T]
to functions taking&U
whereU
isa
Vec<T>
. It can be seen as an alternative to theEquiv
trait, as ithandles all of the common cases well, without requiring a new trait and
new equiv methods. Methods like
find_with
on TreeMap taking a closurewith an equivalent
Ord
implementation are still useful.Closes #14549