Skip to content

Confusion around Sizedness bound for trait objects #50

Answered by pretzelhammer
runiq asked this question in Q&A
Discussion options

You must be logged in to vote

Now, to me that implies that whenever I would implement any trait for a type, that type would automatically gain the ?Sized bound. But that obviously cannot be true. So—what am I missing here? 🤔

I think your confusion might stem from how you're interpreting ?Sized. So if ?Sized meant "is not sized" then yes. as an auto-bound on all trait impls it would not make sense since a lot of types are sized, however what it actually means is "may not be sized" and any type may or may not be sized, just like any boolean may be true or may be false :)

In short: some types are Sized, some are types !Sized, and all types are ?Sized, since ?Sized is the superset of Sized + !Sized. Does that answer you…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@runiq
Comment options

@pretzelhammer
Comment options

Answer selected by runiq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants