#RustQuiz: what will be the output?

A. false
B. true
C. Compilation error
D. unsafe block is missing

#rustlang #rust

@AstraKernel Ohhh, that's a tricky one. I honestly have no clue. I am even unsure if debug and release will yield the same result here.
@AstraKernel That said: I think the result is true. I don't know the actual reasoning behind this, but if I remember correctly, Rust does not create an actual in-memory representation of instances of types with cardinality 1, as those would all be identical anyhow...
One consequence - again iirc - is that all instances of a type with cardinality 1 have the same address.
@soulsource @AstraKernel
I'm a little unsure if there's actually a guarantee that taking two references to the same ZST will return the same pointer.

@hjvt @soulsource @AstraKernel But what of two ZSTs composed together in another ZST?

The array here is itself zero-sized; is there no guarantee that a pointer to an array element must be pointing to an address inside the array? Which would necessitate that the array and the two elements all have the same address?

I am unreasonably fascinated by this problem ^_^

Rust Playground

A browser interface to the Rust compiler to experiment with the language

@AstraKernel @hjvt @soulsource Ha! But now I really wonder if there is a guarantee for that