« first day (985 days earlier)      last day (2497 days later) » 

2:49 PM
@MatthieuM. nice propaganda
 
3:00 PM
:)
Do you have some kind of "watch" setup on answers' updates?
 
@MatthieuM. Yep
(new style UI, if that matters)
 
4:01 PM
@Shepmaster Regarding your comment on the recent iterator post, how is it solvable?
Other than just always using a reference instead of trying to iterate on the struct itself
 
@PeterHall Yeah, if the OP is ok with implementing iterator for &Foo, then it works
but there's something odd there
 
if &Foo: Iterator, then you can do foo.take(1).next(), but not foo.next()
you can also do (&foo).next()
which seems inconsistent
I also updated the linked one because it deals with mutating the underlying struct whereas this one has no mutation of self
 
He can also solve it by making the iterator take a reference to the value
 
@PeterHall Yeah, that'd be my solution too (and then use iter::repeat)
 
4:05 PM
Actually, cleaner would be to implement IntoIter instead of Iterator
@Shepmaster Yeah. Given the way he wants to do it though.
 
@PeterHall yeah, usually IntoIter is better, but I'm never sure how much to try to blow people's minds
 
Ok. Well I'll try that as an answer, if no one else is currently frantically typing one
 
@PeterHall Nah, I put myself in the penalty box
Cause I closed it as a dupe then reopened it
 
4:20 PM
Actually, implementing IntoIterator has the same issue, I think
since into_iter() doesn't have its own lifetime constraint.
 
 
1 hour later…
5:42 PM
@PeterHall implementing IntoIterator works just fine
0
A: How do I specify the lifetime for the associated type of an iterator that refers to itself but does not mutate itself?

Francis GagnéWhen designing an iterator, it's often useful to have distinct types for the collection and for the iterator over that collection. Usually, the collection will own the data, and the iterator will borrow from the collection. Collection types typically implement IntoIterator and don't implement Ite...

 
@FrancisGagné Ah. I think I did something silly, thinking into_iter() borrowed self rather than moving it.
 
your edit just invalidated my second paragraph :S
 
oh! Oops.
 
fixed :P
 
I just deleted the wrong parts of mine, with total disregard for anyone else!
 
6:14 PM
> try with &mut None
The compiler tells you what to doooooo!!!!
 
Yeah. It's of a class of questions which doesn't have dupes because it really shouldn't exist.
But it's such a quick answer, I would prefer to help out a beginner
Though it's very unlikely to help anyone else
 
@PeterHall yeah, I have no disagreement that it is a question, and on-topic and all that
but it certainly doesn't show any research effort :-)
 
Sometimes answers are so obvious you look right past them
 
it's also possible that the OP has ye olde compiler.
 
Possible. Is some old version shipping with some linux distros?
 
6:28 PM
@PeterHall I expect so. Distros like to roll slow
 
This actually might be a legitimate occasion where an answer doesn't deserve an upvote :)
 
 
3 hours later…
9:39 PM
every time, there is a lifetime in rust code, the color fuck up. How could we help SO to add rust syntax color ?
 
@Stargateur not every time
when there are more than one on a line
@Stargateur But it uses github.com/google/code-prettify
so you can fix it there!
 
I will try to look but I don't know JS and I don't want to learn it. ^^
I just code a little with typescript
I understand why this is clearly not perfect.
 
10:01 PM
@Stargateur Back in the day, there was no rust formatting
If you stumble across old questions, they will be formatted like this
    fn foo<'a>(a: &'a u8, b: &'a u8) { // 'a
because the odd number of ' could be cancelled out via the comment
 

« first day (985 days earlier)      last day (2497 days later) »