snaggen@programming.dev to Rust@programming.dev · 9 months agoAnnouncing Rust 1.76.0blog.rust-lang.orgexternal-linkmessage-square25fedilinkarrow-up1101arrow-down10
arrow-up1101arrow-down1external-linkAnnouncing Rust 1.76.0blog.rust-lang.orgsnaggen@programming.dev to Rust@programming.dev · 9 months agomessage-square25fedilink
minus-squareanlumo@feddit.delinkfedilinkEnglisharrow-up15arrow-down2·9 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-squarexav@programming.devlinkfedilinkarrow-up1·9 months agoWarning: in the first case “value” is actually a shared reference, not a value.
is equivalent to
Elegant. Thanks!
Warning: in the first case “value” is actually a shared reference, not a value.