inline-dyn/README.md
2026-09-23 22:08:51 +03:00

10 lines
470 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Inline `dyn`
A relatively simple example wrapper working (kinda) as a *by-value* `dyn Trait`.
Limitations:
* The wrapper size is fixed. The content either fits, or it doesn’t compile.
* Supporting each trait requires a bit of code, as there is no way to express “for each *trait* X” in Rust.
* Requires unstable features (notably `ptr_metadata`, others are probably avoidable).
* `unsafe` here, `unsafe` there, `unsafe` everywhere! (It does pass Miri though).