I watched jonhoo's stream and while I was distracted with other things I heard it mentioned that Option<Vec<T>>
can be optimized so that it uses the vector's internal list pointer to indicate whether it's Some
or None
. Unfortunately because I was focused on other things, I didn't quite get the context under which this happens.
Are these types of quote-specializations-endquote something that is completely built into the compiler (i.e. it knows about Option<Vec<T>>
specifically), or is this something one could hint the compiler about in library code? Conceptually:
struct MyThing {
#[if_this_is_null_it_can_be_regarded_as_none]
ptr: *const u32;
}
Or is it based on things like NonNull
?