Function ghosts::materialize
source · [−]pub fn materialize<T>(_: Ghost<T>) -> T
Expand description
Ghost operation: extract an imaginary T
value out of a Ghost<T>
token.
THIS MUST ONLY BE USED FROM WITHIN A ghost!
BLOCK
Or somewhere transitively called by a ghost!
block exclusively.
Otherwise this call would try to make it to codegen, which it cannot do.
- the current implementation uses a polymorphization limitation to prevent
this, which works, but is not detected by
cargo check
.
Non-error-prone replacements
-
When directly inside a
ghost!
block, usematerialize!
. -
Otherwise, require that the caller pass some
Ectoplasm
, which they can have bymaterialize()
-ing their ownGhost<Ectoplasm>
.With it, you’ll have access to its impossible to misuse
.materialize()
method. -
Or perhaps way more simply, consider using the
.map()
or.and_then()
adapters.