|
Minus Pants posted:I'm writing an app that does some basic network performance tests, and I'd like to be able to format some types from std in my print calls (e.g. std::net::SocketAddr). I stumbled around trying to implement the Display trait, which doesn't work because it's an external type. What's the idiomatic way to handle this? Make a wrapper type? Formatter function? code:
|
# ¿ Apr 17, 2020 03:29 |
|
|
# ¿ May 13, 2024 01:27 |
|
gonadic io posted:Just `x >> 8` does that, no? Rust u32's shr fills with zeroes. code:
|
# ¿ Feb 8, 2023 02:29 |
|
As far as I can tell you're running into the common issue where if let has a funky scope and even though you're returning from inside it, its borrow lasts until the outer scope ends. If that's the case one of the workarounds is to put the whole if let inside its own scope to force the borrow to be released. One of my least favourite rust constructs is the suggested workaround if your if let returns an owned/Copy item: code:
Yes that temporary binding is necessary. Threep fucked around with this message at 17:08 on Jul 4, 2023 |
# ¿ Jul 4, 2023 17:02 |