@catoutofbed hm

I wonder if returning an Option<T> is equivalent to returning a Result<T, E> where E is a zero-field struct

Follow

@iliana @catoutofbed@octodon.social doesn't Option<T> compile down into a single pointer that might be null?

@lizardsquid @catoutofbed @iliana It's Option<&T> that compiles to a single pointer, as does any similar enum wrapped around any NonZero type. In general, Option<T> can't necessarily avoid having a separate tag field.

I think Result<T,E> should have the same size as Option<T> any time T is at least as big as E, including when E is zero-size. I believe there are special cases though, like that Result<T,!> has the same representation as T because the type proves the Err case can't happen.

Sign in to participate in the conversation
Computer Fairies

Computer Fairies is a Mastodon instance that aims to be as queer, friendly and furry as possible. We welcome all kinds of computer fairies!