Module show_notes::e014::demo_deref

source ·
Expand description

Demonstrate dereferencing. (You’ll want to read this example carefully.)

Note that here we have two types which are empty of values, which makes the dereferencing operation quite straightforward. If the types had contents, this would be a bit more involved!

Note as well that the dereference in this case recurses. This is a consequence of having the empty types—so it’s not exactly recommended to do this in that case! (In fact, it’s usually, though not always, pointless to do that.)

Structs

  • A no-content struct to serve as the target to dereference to.
  • A no-content struct to serve as the type to dereference from.