HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · edit-21 year agoWhy make it complicated?lemmy.mlimagemessage-square123fedilinkarrow-up1371arrow-down138file-textcross-posted to: programmerhumor@lemmy.ml
arrow-up1333arrow-down1imageWhy make it complicated?lemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · edit-21 year agomessage-square123fedilinkfile-textcross-posted to: programmerhumor@lemmy.ml
minus-squarenebeker@programming.devlinkfedilinkEnglisharrow-up8·1 year agolet a = String::from(“Hello, world!”).into() I’ll see myself out.
minus-squareanton@lemmy.blahaj.zonelinkfedilinkarrow-up4·1 year agoAt least be fair and cut out the .into()
minus-squarenebeker@programming.devlinkfedilinkEnglisharrow-up3·1 year agoAnd bow to the compiler’s whims? I think not! This shouldn’t compile, because .into needs the type from the left side and let needs the type from the right side.
minus-squareHaradion@lemmy.mllinkfedilinkarrow-up3·11 months agoIf type constraints later in the function let the compiler infer the type, this syntax totally works.
minus-squarenebeker@programming.devlinkfedilinkEnglisharrow-up1·11 months agoLike if the variable is then used in a function that only takes one type? Huh.
let a = String::from(“Hello, world!”).into()I’ll see myself out.
At least be fair and cut out the
.into()And bow to the compiler’s whims? I think not!
This shouldn’t compile, because .into needs the type from the left side and let needs the type from the right side.
If type constraints later in the function let the compiler infer the type, this syntax totally works.
Like if the variable is then used in a function that only takes one type? Huh.