dyn-context
This crate provides simple mechanism for lifetimes and generics safely erasing.
-
Erasing lifetimes.
In Rust, lifetimes are intrusive, and sometimes it can lead to an inadequately complex code. Moreover, in some cases it can lead to an impossible code, means code so complex, so it can not make to compiles, even it is logically meaningful. (Such situations could occur because Rust does not support existential types with infinite parameters list.)
The crate provides a way to "compress" several lifetimed references into a one reference to a
'static
type. This mechanism guarantees type-safety. -
Erasing generics.
There are many reasons, why generics could be not a best choice in some concrete situation. This library provides
Context
trait, which may be helpful in such cases.
Combining both mechanics (lifetimes compression and dynamic context trait) allows to build complex systems with callbacks:
use ;
use CallBack;
free_lifetimes!
Context!;