Go to file
2026-09-24 18:42:15 +03:00
src factor out common code out of per-trait implementation 2026-09-23 22:03:16 +03:00
.gitignore It... works? 2024-08-23 01:04:15 +03:00
Cargo.lock It... works? 2024-08-23 01:04:15 +03:00
Cargo.toml It... works? 2024-08-23 01:04:15 +03:00
README.md add note on no by-value methods 2026-09-24 18:42:15 +03:00
rust-toolchain.toml It... works? 2024-08-23 01:04:15 +03:00
rustfmt.toml It... works? 2024-08-23 01:04:15 +03:00

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.
  • Like with Box<dyn _>, you can’t call by-value methods on the content.
  • Requires unstable features (notably ptr_metadata, others are probably avoidable).
  • unsafe here, unsafe there, unsafe everywhere! (It does pass Miri though).