Adapter in Rust
Adapter is a structural design pattern, which allows incompatible objects to collaborate.
The Adapter acts as a wrapper between two objects. It catches calls for one object and transforms them to format and interface recognizable by the second object.
Adapter in Rust
In this example, the trait SpecificTarget
is incompatible with a call
function which accepts trait Target
only.
The adapter helps to pass the incompatible interface to the call
function.