« first day (2656 days earlier)      last day (816 days later) » 

12:07 AM
I've been writing so much C lately for work and TOCTOUs are so hard to avoid
it's usually much easier to check first instead of doing things properly
 
 
6 hours later…
6:01 AM
@trentᶠᵒʳᵐᵉʳˡʸᶜˡ there is also not always the api call to do it
for example you can't create a directory and open it atomically on linux
 
 
5 hours later…
11:28 AM
Hi guys, I have trouble understanding pattern matching when it comes to references. I have an Iter<(&str, &str)> and want to find the first element where the first &str equals some needle. .find()'s predicate takes &(&str, &str) so I can do |&pair| needle == pair.0. Now I am wondering why |&(x, _)| needle == x doesn't work. It says "can't compare str with &str". My IDE says x has type &&str but I don't understand why and I don't know how to fix it.
 
@purefanatic Since x in (x, _) is behind a reference to the tuple, the x itself inherits that indirection, so it becomes a &&str. The pattern &(x, _) does not automatically deref this extra reference.
Doing |(x, _)| needle == *x should work.
 
12:01 PM
I hate when a library does this
How do I even find where is the allocation problem in their code ?
Also, that's a lot of bytes
 
I would assume the allocation is out of the library's control.
 
The library asks for something that is beyond reasonnable
(it's syntect, which also unfortunately panics in other places)
The thing is, I don't really know how to find where it does this without spending hours adding logs in their code (or bisecting)
 
What, why did I receive an upvote 5 seconds after posting the answer? :(
People are quick to upboat
 
@DenysSéguret always check closed issue too :p
but it's strange don't they say they yank the version ?
 
yeah
They yanked it
 
how did you end up used it so ?
 
But still there's no obvious warning that the current repo is a mess
 
bad luck ?
 
12:31 PM
@Stargateur because the last non yanked version has a panic and I wanted to check whether it was still present to fix it
Libraries like this should never panic IMO...
 
@DenysSéguret I suggest you panic_unwind call to this crate
I totally agree
IMO no lib should panic :p
 
 
2 hours later…
2:21 PM
@E_net4theprolificdownvoter Thanks, this works. I'm afraid I still don't quite understand what is going on. For example, why are |(x, _)| and |&(x, _)| equivalent here? Why doesn't |(&x, _)| needle == extension work? I wasn't able to find relevant documentation, so if you know any please share and I'll stop asking stupid questions ;-)
 
At least for your first question.
For the second question, it was a bit of a surprise myself, but the pattern appears to auto-deref x into str.
 
Thanks again. Yeah I also thought about auto-dereferencing, but couldn't quite put my finger on it. Regarding those match ergonomics I must say I wouldn't mind adding some & and * from time to time for more explicitness... At least for me as a newbie all this magic is very confusing
 
2:46 PM
FWIW this works.
 
3:08 PM
I see. Therefore .iter().filter(|&&(x, _)| needle == x) also works (edit: and it makes sense, too). Why didn't I even try that before? :D
 
3:26 PM
@Stargateur I'm looking into forking it and adding error handling. The crate is full of panic and unwrap...
 
3:37 PM
@purefanatic Ah, so yes, the original tuple was &&(&str, &str), so by doing &(x, _), we'd only be dereferencing one of them. :)
@DenysSéguret Ugh
 
 
2 hours later…
5:33 PM
@DenysSéguret I really advice a temporary catch unwind, you will have hard time maintain a syntax highlight lib is a collosal work
I expect you don't have a lot of place you call this crate
do a wrapper add your own error syntect_panic and use the wrapper instead of the crate
it's will be ok tier in term of perf
 
5:52 PM
@Stargateur I'll try that. But if I fork, it would be only temporary, waiting for a less buggy version.
 
I don't believe it will happen
 
Hum... Too many things to change due to UnwindSafe boundaries problems
 
6:54 PM
Pfff... I'm currently adding error handling everywhere in my forked syntect ^^
 
 
3 hours later…
9:40 PM
@Stargateur I did the fork. It works. github.com/Canop/broot/commit/…
 
@DenysSéguret ah
in that case
yeah
 
I don't get that they noticed the numerous panics in 2017 and just didn't do what I did...
BTW most of the my work in the first 3 days in my new startups was on finding solutions to remove about 200 unwrap. This was more fun and interesting that it looks :)
 
@DenysSéguret yay!
 
10:01 PM
afk testing the settlers
 

« first day (2656 days earlier)      last day (816 days later) »