« first day (5075 days earlier)      last day (63 days later) » 

02:32
@Ginger Fun fact: your new server's IP starts with 192, which wasn't confusing at all the first time I pasted it
03:10
omw to get banned from the CMU subreddit
 
2 hours later…
05:31
Okay Rust makes me mad 9 times out of 10 but sometimes it really just works
306
A: How do I stop iteration and return an error when Iterator::map returns a Result::Err?

BurntSushi5Result implements FromIterator, so you can move the Result outside and iterators will take care of the rest (including stopping iteration if an error is found). #[derive(Debug)] struct Item; type Id = String; fn find(id: &Id) -> Result<Item, String> { Err(format!("Not found: {:?}", id)) } ...

 
2 hours later…
07:10
thanks google
 
1 hour later…
08:33
Use of collect() requires the iterator to be finite, correct? If so, how would a similar but infinite iterator be handled? — U007D Mar 4, 2019 at 21:36
WTF is the expected result for a infinite iterator? Are they expecting Rust to do calculus?
09:14
They're asking how would you stop execution and throw an error if it's infinite
The collect approach obviously won't work
78
A: How do I stop iteration and return an error when Iterator::map returns a Result::Err?

user4815162342The accepted answer shows how to stop on error while collecting, as requested in the question. However it won't help with large or infinite fallible iterators, or when the iterator is collected by code you don't control. If your use case is one of those, read on. As already noted, for can be used...

That answers the comment
@lyxal Collect works fine, you can collect into () which effectively just discards the values.
Ah the question is not asking about collect at all, that's why the comment makes no sense
 
2 hours later…
11:21
CMC "Parimeter" of circle. Given r, count integer pairs (x,y) such that x^2+y^2<r^2 and, at least one of (x±1,y) and (x,y±1) don't
 
3 hours later…
14:22
@lyxal funnily enough, just yesterday I was going crazy thinking, "why the hell does Rust have try_fold and try_for_each but no equivalent of Haskell's traverse???", until I found out by dumb luck that oh it's literally just a thing FromIterator implicitly does
Considering how hard it is to find + people not liking to have to turbofish too hard I can't help but think an explicit try_collect or some such could be appropriate too though
(granted I've actually managed to use it without a turbofish more often than not since I happen to be using it in an if let Some( ... ) :D)
@UnrelatedString There is a proposal for it: github.com/rust-lang/rust/issues/94047
The semantics are a bit different though, the purpose is to allow resuming the iterator after a failure
In fact the main objection is most people who look for this are actually better of using normal collect
And before anyone asks, "wait since when does she actually write Rust?", I'm doing this casual one-week game jam the club's hosting over break, and I'm... writing a massively overengineered localization key system for it before implementing any gameplay or graphics at all
@mousetail'he-him' interesting
yeah I feel like at that point you either want normal collect or to just bite the bullet and write a for loop because you're doing Something Wild
or, like, whatever the take-while is called
because if you're resuming after an error you're probably not treating it that much like an error
By "resuming after an error" it just means it leaves the rest of the items in the iterator. So you can re-use it and get the rest of the items out later if you like
14:38
yeah
I imagine there might be weird situations where you might want to exhaust the iterator for side effects even after an error
ooooh
That's a good point
 
3 hours later…
17:50
Was doing my laundry this morning, and had to move a load to the dryer that had been left in the washer overnight (as is... often the case here)
Noticed a singular popcorn kernel and just laughed about it for a bit; told my sister and she said (paraphrasing) "oh yeah that's probably from the popcorn bag [cloth with drawstrings, not like a paper bag for microwave popcorn lol] I washed"
Thought nothing of it as I loaded everything into the dryer
fast-forward to 10 minutes ago when I just remembered my wash was probably done like 2 hours ago... there were like 15 or 20 kernels just lined up on
and then when I finished emptying the dryer I noticed that the bag in question... had its drawstrings tightened...
there were still flecks and crumbs of stuff inside it; she never even turned it inside out
hmmmmmmmmmmmm
 
4 hours later…
21:31
Pressure units are so cursed...you've got:
- PSI, which is easy to physically intuit, but uses imperial units
- Pascals, which are nice and SI, but impractical
- mmHg, which is dependent on the definition of Celsius, the mass of the earth, its sea level, and the density of mercury
- Torr, which are like mmHg but off by such a tiny amount you can treat them as interchangeable and feel guilty about it until you go to the grave
- Atm, which is 760 torr because why not
- Bar, which is defined nicely in terms of Pascals, but with the same mmHg-Torr sorta relationship going on with atm
also cmhg appears in some archaic documents
We should at least try to make it SI. Meters of mercury or nothing.
21:48
@rydwolf the only units i use, like, ever are PSI and atm
PSI for daily stuff and atm for nerd stuff
bar none?
5
yup :P
att
att
@UnrelatedString wait what is a popcorn bag
Literally just a cloth bag she stored popcorn in
for like, bringing places
to snack on
specifically popped popcorn but those unpopped kernels were just. still in there
att
att
22:12
shouldn't you empty the bag before washing..?
YES.
this apparently did not occur to her ;_;
The concept of a popcorn bag you wash in a clothes washing machine is not something I have encountered before I must say
me neither...
23:14
@rydwolf same

« first day (5075 days earlier)      last day (63 days later) »