Constants and dyn-compatibility

⚓ Rust    📅 2025-09-03    👤 surdeus    👁️ 10      

surdeus

Warning

This post was published 90 days ago. The information described in this article may have changed.

Is there any hard reason why traits with constants inside cannot be made dyn-compatible?

From what I understand it should be possible to build a vtable with constants inside.

Is it something that just wasn't implemented or is the solution non-obvious for some reason?

As a workaround I currently implemented a constant through a method taking &self. It works, but it can be abused to return a different value on further invocations.

3 posts - 2 participants

Read full topic

🏷️ Rust_feed