Advent of Code Peer Review
4:13
19 сағат бұрын
Code Walkthrough of 2.0 of cmd
12:46
Super Extra bonus video for cmd
14:58
Пікірлер
@elmigranto
@elmigranto 5 күн бұрын
Neat. But I have hard time undertanding how assembly could possibly be the same. I tried comparing on godbolt, but don't know Rust well enough to make it work. Would be grateful if anyone can link to what each version produces.
@GlobalYoung7
@GlobalYoung7 2 ай бұрын
Thank You
@flatmapper
@flatmapper 5 ай бұрын
This is interesting
@pinchonalizo
@pinchonalizo 5 ай бұрын
Very interesting topic John! As a newer Rustacian I think it would be helpful to explicitly write out “return” when returning the Fn in the function implementation of this. As a side note, the function version of this logging mechanism is very akin to creating decorators in Python. It essentially adding external functionality to a function by wrapping it in another function.
@pinchonalizo
@pinchonalizo 7 ай бұрын
I think Nix-shell does something very similar for development environments that get completely erased upon terminating the process. See nixos.wiki/wiki/Development_environment_with_nix-shell
@pinchonalizo
@pinchonalizo 7 ай бұрын
this is great. Fool proofing the Server creation such that the user can't create one without an error_handler and also eliminating code paths all at once.
@pinchonalizo
@pinchonalizo 7 ай бұрын
Lots of wisdom at the end relating to how testing exposes paths we wouldn't otherwise think of as well as helping find an implementation that is better.
@pinchonalizo
@pinchonalizo 7 ай бұрын
I had no idea that hashing Some(T) and None was allowed. That was cool
@pinchonalizo
@pinchonalizo 7 ай бұрын
"A little wonky but it feels right" 😂
@pinchonalizo
@pinchonalizo 7 ай бұрын
Watching this already having gone through the pain of figuring out that read_to_end blocks on an open TCP stream connection was entertaining. Especially seeing the poor Workers get axed 😂
@aughey
@aughey 7 ай бұрын
read_all will also block, but you give it an explicit size to read. However, if there is a slow sender, or a sender that is intentionally not giving a body to a post, it will exhaust your threads because they'll all be sitting there trying to read the body that will never come. Clients that behave correctly won't have this issue, but it's an issue nonetheless. The issue with read_to_end is that it's looking for a closed stream and a client using http 1.1 will attempt to keep the connection open. In your case, handling get, there is no content length and you set content length to 0, so reading all of length 0 returns right away regardless.
@pinchonalizo
@pinchonalizo 7 ай бұрын
Amazing how the use of generics becomes dependency injection and results in the ability to mock types/methods for basically free
@pinchonalizo
@pinchonalizo 7 ай бұрын
kzbin.info/www/bejne/hIW5fIiHo6apesUsi=AmrN2NF_qVPkseCH&t=825 tiny bit of black magic here? Does passing a reference of an Arc clone into a function as an arg automatically coerce the reference of the arc to a reference of the inner value? We just passed an &Arc::clone(HashMap<foo>) and it was coerced into an &Hashmap<foo>, is that correct?
@pinchonalizo
@pinchonalizo 7 ай бұрын
Awesome explanation. Anyhow makes such a big difference in the amount of code it takes to propagate errors. It seems the thing to analyze when using it is the tradeoff in not being able to deconstruct errors into their component parts. The challenge here is to make it a habit to think through when slapping on the `?` everywhere and instead making it a habit to at least consider if deconstructing the error is necessary. I agree with your take, 9/10 times it will not need to be deconstructed.
@pinchonalizo
@pinchonalizo 7 ай бұрын
Brilliant🤯
@pinchonalizo
@pinchonalizo 7 ай бұрын
“The compiler is a surfer that says dude”😂 🏄‍♂️ 🤙
@pinchonalizo
@pinchonalizo 7 ай бұрын
A lot of people are facing the same issue on stackoverflow, but I believe buffer.read_all will try to find an EOF which will never come. This causes the read_all call to block, until the client closes the connection. However the client will not close the connection until it receives a response from the server while the server is blocking on waiting for the EOF. Ultimately the client times out and closes the connection but by then it is too late. I believe a better alternative is to use read_exact instead based on the Content-Length field provided in the HTTP request from the client. Any thoughts?
@pinchonalizo
@pinchonalizo 7 ай бұрын
This has been my favorite refactor so far. Subscribe button hit