Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement .iter to DOMRectList #11162
Conversation
| @@ -57,3 +66,18 @@ impl DOMRectListMethods for DOMRectList { | |||
| self.Item(index) | |||
| } | |||
| } | |||
|
|
|||
| impl<'a> Iterator for Iter<'a> { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cbrewster
May 12, 2016
•
Member
Iter stores the current position, but perhaps it would be better to rename Iter to IterableDOMRectList or DOMRectListIterator
This comment has been minimized.
This comment has been minimized.
jaysonsantos
May 13, 2016
Author
@KiChjang I though that but it would mutate the DOMRectList and it would only be iterated once because of position. Does it make sense?
@ConnorGBrewster I used the same naming as in the std, is better to change it?
This comment has been minimized.
This comment has been minimized.
KiChjang
May 13, 2016
Member
Actually, the better question here is why not simply return self.rects.iter() in fn iter.
This comment has been minimized.
This comment has been minimized.
jaysonsantos
May 13, 2016
Author
I am maitaining Item signature which is Root<DOMRect> and self.rects is a vector of JS<DOMRect>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ms2ger
May 13, 2016
Contributor
You can't return that from a function. However, it would probably be better to store self.rects.iter() in a field of Iter and then return self.inner.next().map(|rect| Root::from_ref(&*rect)) from next().
|
I don't understand, why do we need a specific iterator instead of just returning a |
|
@nox I don't know either :) I am just starting at this business. But to return it I would have to iterate over all rects to make it, no? And it wouldn't be |
|
Superseded by #11171. |
jaysonsantos commentedMay 12, 2016
•
edited by larsbergstrom
This will be used in #10828 but I made thins in a splited PR because the other one is pretty hard to get working and this iterator still would be useful.
This change is