I would like to share about my intuition for SubTrait: SuperTrait
.
Let's think this way:
the definition of
subset A = { types required to live for 'long lifetime }
and
superset B = { types required to live for 'short lifetime }
is correct because that's to say
any type living for 'long is a type living for 'short[1].
A variable living for 'long
can naturally shorten -- you can ask a variable living for 'long to just live for 'short.[2]
We don't think the case that any type living for 'short
is a type living for 'long
is correct:
obviously you cannot ask a variable only living for 'short to live for 'long.
The point here is to always stand in the perspective of types. Not in the perspective of lifetime itself -- the region where a value/reference is alive.
And the key concept for subtyping I learnt from Jonhoo's video, which has been posted above, is "usability".
Subtypes are more usable than supertypes for various reasons. Like for 'static: 'any
, we don't manually and explicitly cast a 'static
variable to a new one with a shorter lifetime, so 'static
is more usable (and easy to use).