Ephera to Programmer HumorEnglish · 1 year agoAfter a day of coding Rust...imagemessage-square7fedilinkarrow-up1205arrow-down17
arrow-up1198arrow-down1imageAfter a day of coding Rust...Ephera to Programmer HumorEnglish · 1 year agomessage-square7fedilink
minus-squarelseif@sopuli.xyzlinkfedilinkarrow-up1·1 year agois that valid syntax in any context? i dont think it is
minus-squareEpheraOPlinkfedilinkarrow-up4·1 year 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<dyn Sized> 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<dyn Sized>
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 :-)