A Gopher Meets a Crab
miren.dev
A Gopher Meets a Crab
1–10 of 79 posts
Re: A Gopher Meets a Crab
#2 Result>, Elapsed>
That’s three independent “not the happy path” channels: timeout, stream closed,
and websocket error.The nicer version is not a cleverer match. It’s choosing a domain error shape and converting into it one layer at a time:
let timed = tokio::time::timeout(duration, receiver.next()).await;
let next = timed.map_err(|_| ReceiveError::Timeout)?;
let item = next.ok_or(ReceiveError::Closed)?;
let msg = item.map_err(ReceiveError::WebSocket)?;
The ugly line is what happens when you have not decided where to normalize the
shape yet.Re: A Gopher Meets a Crab
#3The weird-looking Rust isn’t really Rust being weird, it’s the type telling the truth. Result >, Elapsed> That’s three independent “not the happy path” channels: timeout, stream closed, and websocket error. The nicer version is not a cleverer match. It’s choosing a domain error shape and converting into it one layer at a time: let timed = tokio::time::timeout(duration, receiver.next()).await; let next = timed.map_err…
Result
Is pretty weird, though, no? Why would you want a unit value / error type?Re: A Gopher Meets a Crab
#4Re: A Gopher Meets a Crab
#5The weird-looking Rust isn’t really Rust being weird, it’s the type telling the truth. Result >, Elapsed> That’s three independent “not the happy path” channels: timeout, stream closed, and websocket error. The nicer version is not a cleverer match. It’s choosing a domain error shape and converting into it one layer at a time: let timed = tokio::time::timeout(duration, receiver.next()).await; let next = timed.map_err…
Re: A Gopher Meets a Crab
#6The weird-looking Rust isn’t really Rust being weird, it’s the type telling the truth. Result >, Elapsed> That’s three independent “not the happy path” channels: timeout, stream closed, and websocket error. The nicer version is not a cleverer match. It’s choosing a domain error shape and converting into it one layer at a time: let timed = tokio::time::timeout(duration, receiver.next()).await; let next = timed.map_err…
Result Is pretty weird, though, no? Why would you want a unit value / error type?
Re: A Gopher Meets a Crab
#7The weird-looking Rust isn’t really Rust being weird, it’s the type telling the truth. Result >, Elapsed> That’s three independent “not the happy path” channels: timeout, stream closed, and websocket error. The nicer version is not a cleverer match. It’s choosing a domain error shape and converting into it one layer at a time: let timed = tokio::time::timeout(duration, receiver.next()).await; let next = timed.map_err…
Result Is pretty weird, though, no? Why would you want a unit value / error type?
That said, a couple of the examples here feel a bit strange - they're clever things you can do, but they're not necessarily things you often have to do, particularly for a relatively simple task like this. I think the problem with the author's approach is that they can't distinguish between "weird because Rust is weird" and "weird because the LLM generated bad code", because they (understandably) don't have enough experience in what good Rust code looks like.
Re: A Gopher Meets a Crab
#8The weird-looking Rust isn’t really Rust being weird, it’s the type telling the truth. Result >, Elapsed> That’s three independent “not the happy path” channels: timeout, stream closed, and websocket error. The nicer version is not a cleverer match. It’s choosing a domain error shape and converting into it one layer at a time: let timed = tokio::time::timeout(duration, receiver.next()).await; let next = timed.map_err…
Result Is pretty weird, though, no? Why would you want a unit value / error type?
Re: A Gopher Meets a Crab
#9Was anyone else expecting OpenClaw over gopher protocol?
Re: A Gopher Meets a Crab
#10a) Vibe coding produces bad code
b) Rust is weird
Somehow we’re supposed to accept b as the answer? Give me a break….