Module drop_bomb

Source
Expand description

Drop bombs, for assurance of postconditions when types are dropped

Provides two drop bomb types: DropBomb and DropBombCondition.

These help assure that our algorithms are correct, by detecting when types that contain the bomb are dropped inappropriately.

§No-op outside #[cfg(test)]

When used outside test code, these types are unit ZSTs, and are completely inert. They won’t cause panics or detect bugs, in production.

§Panics (in tests), and simulation

These types work by panicking in drop, when a bug is detected. This will then cause a test failure. Such panics are described as “explodes (panics)” in the documentation.

There are also simulated drop bombs, whose explosions do not actually panic. Instead, they record that a panic would have occurred, and print a message to stderr. The constructors provide a handle to allow the caller to enquire about explosions. This allows for testing a containing type’s drop bomb logic.

Certain misuses result in actual panics, even with simulated bombs. This is described as “panics (actually)”.

§Choosing a bomb

DropBomb is for assuring the runtime context or appropriate timing of drops (and could be used for implementing general conditions).

DropBombCondition is for assuring the properties of a value that is being dropped.

Macros§

derive_deftly_template_BombImpls 🔒
Helper for common impls on bombs

Structs§

DropBomb 🔒
Drop bomb: for assuring that drops happen only when expected
DropBombCondition 🔒
Drop condition: for ensuring that a condition is true, on drop

Enums§

Status 🔒
State of some kind of drop bomb

Traits§

DropStatus 🔒
Core of Drop, that can be called separately, for testing