@snaggen to Rust • 5 months agoAnnouncing Rust 1.76.0blog.rust-lang.orgexternal-linkmessage-square23arrow-up1104arrow-down10
arrow-up1104arrow-down1external-linkAnnouncing Rust 1.76.0blog.rust-lang.org@snaggen to Rust • 5 months agomessage-square23
minus-square@[email protected]linkfedilinkEnglish13•5 months agolet bar: Result<T, E> = ...; let foo = bar.inspect(|value| log::debug("{}", value)); is equivalent to let bar: Result<T, E> = ...; let foo = bar.map(|value| { log::debug("{}", value); value });
minus-square@xavlink1•5 months agoWarning: in the first case “value” is actually a shared reference, not a value.
let bar: Result<T, E> = ...; let foo = bar.inspect(|value| log::debug("{}", value));
is equivalent to
let bar: Result<T, E> = ...; let foo = bar.map(|value| { log::debug("{}", value); value });
Warning: in the first case “value” is actually a shared reference, not a value.
Elegant. Thanks!