pub struct Behold<T>(/* private fields */);
Expand description
Return type for operations which require attention from the caller.
Such operations may lead to data corruption or return data that may be misleading in some
circumstances. In other scenarios, Behold
marks seemingly “innocent” methods or functions,
that perform costly operations, clone large amounts of data, or spawn treads. By any means, this
is just a reminder for the caller that certain aspects of the operation require their close
attention.
In some sense, Behold
serves as an opinionated replacement for a relatively widespread
practice of marking with unsafe
methods and functions that, while being safe from the Rust
perspective, still require certain care from the caller. We’ve decided to refrain from such
practice since: (a) some projects may restrict using unsafe Rust, (b) our use cases do not
strictly coincide with operations, that may lead to undecided behavior (even in wider sense).
Once Behold
is obtained, the caller can either explicitly accept the consequences,
retrieving the result by calling Behold::unwrap
, or discard the value with
Behold::discard
.