Ephera to Programmer Humor@lemmy.mlEnglish • 6 months agoAfter a day of coding Rust...lemmy.mlimagemessage-square7fedilinkarrow-up1197
arrow-up1197imageAfter a day of coding Rust...lemmy.mlEphera to Programmer Humor@lemmy.mlEnglish • 6 months agomessage-square7fedilink
minus-square@lseif@sopuli.xyzlinkfedilink1•6 months agois that valid syntax in any context? i dont think it is
minus-squareEpheraOPlinkfedilink4•6 months agoPretty sure, it’s not. That’s why I included the error highlighting. To make it a valid struct field, you’d need to throw in a Box+dyn: pub pint: Box For a function parameter, you need an impl and can’t have the pub: pint: impl Sized Obviously, you could define your own struct or generic that also happens to be called Sized, but yeah, that’s cheating.
is that valid syntax in any context? i dont think it is
Pretty sure, it’s not. That’s why I included the error highlighting.
To make it a valid struct field, you’d need to throw in a Box+dyn:
pub pint: Box
For a function parameter, you need an
impl
and can’t have thepub
:pint: impl Sized
Obviously, you could define your own struct or generic that also happens to be called
Sized
, but yeah, that’s cheating.thats what i figured. thanks :-)