Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upIntroduce remaining Index traits #159
Conversation
This comment has been minimized.
This comment has been minimized.
|
What happens if |
This comment has been minimized.
This comment has been minimized.
|
Yeah, we'd probably want the compiler to forbid "overlapping" definitions. |
chris-morgan
reviewed
Jul 9, 2014
| fn index<'a>(&'a self, element: E) -> &'a R; | ||
| } | ||
| pub trait IndexMut<E, R>: Index<E, R> { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
eddyb
Jul 9, 2014
Member
For the upgrade mechanism required to fix the DerefMut-in-immutable-contexts issue.
Or is it downgrade? In any case, one of IndexMut or Index is picked, and depending on whether the result is required to be a mutable lvalue (e.g. method call with &mut self) or not, the operation will be adjusted to use the more appropriate trait.
This comment has been minimized.
This comment has been minimized.
SiegeLord
commented
Jul 16, 2014
|
Why can't My use case is a matrix type defined like so: struct Matrix<T>
{
elems: Vec<Cell<T>>
} |
This comment has been minimized.
This comment has been minimized.
erickt
commented
Jul 17, 2014
|
I don't think we need
|
This comment has been minimized.
This comment has been minimized.
|
I'm assuming the lifetime parameter in This option is mentioned briefly in the RFC. @alexcrichton had some concerns about it with respect to how the compiler would decide what I am still a bit concerned with the weirdness of the by-value overload setup, but it's not the end of the world, and it seems to add a lot more flexibility. |
This comment has been minimized.
This comment has been minimized.
erickt
commented
Jul 22, 2014
|
@sfackler: Ah, I apparently didn't understand that you meant in that section. I think if we go down my route, are there any situations where a data structure would want to have overlapping implementations of Also, the lifetime was needed, but with perhaps it's unnecessary now that we have lifetime elision? |
nrc
assigned
nikomatsakis
Sep 4, 2014
alexcrichton
force-pushed the
rust-lang:master
branch
from
6357402
to
e0acdf4
Sep 11, 2014
aturon
force-pushed the
rust-lang:master
branch
from
4c0bebf
to
b1d1bfd
Sep 16, 2014
alexcrichton
force-pushed the
rust-lang:master
branch
from
b9e2b8c
to
5020131
Oct 29, 2014
nikomatsakis
referenced this pull request
Mar 21, 2015
Open
Extending deref/index with ownership transfer: DerefMove, IndexMove, IndexSet #997
This comment has been minimized.
This comment has been minimized.
|
This is an important topic, but by now it's clear we won't be getting to this at the moment. I hope we can come back to it shortly after 1.0 though. Postponing along with |
sfackler commentedJul 8, 2014
No description provided.