turbohz@programming.dev to Rust@programming.devEnglish · 2 months agoThe Hidden Rules Behind Rust Functions & Closuresblog.cuongle.devexternal-linkmessage-square4fedilinkarrow-up140arrow-down11cross-posted to: hackernews
arrow-up139arrow-down1external-linkThe Hidden Rules Behind Rust Functions & Closuresblog.cuongle.devturbohz@programming.dev to Rust@programming.devEnglish · 2 months agomessage-square4fedilinkcross-posted to: hackernews
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up9·edit-22 months agoWell, the closure has a type. Just you cannot declare it. That’s why you do “impl Fn” instead. Because you know that whatever type the close is, it implements the “Fn” trait.
Well, the closure has a type. Just you cannot declare it. That’s why you do “impl Fn” instead. Because you know that whatever type the close is, it implements the “Fn” trait.