Izagawd
Izagawd
> An alternative to this would be that we make existing associated constants object-safe. > > Currently, traits with `const` items are not dyn-compatible ([Error `E0038`](https://doc.rust-lang.org/error_codes/E0038.html#trait-contains-associated-constants)). If we simply implemented...
@clarfonthey Trait fields and this RFC are very different though. This RFC is only about per-implementation constant metadata stored in the vtable, not per-instance data or layout/borrowing semantics. Because we...
@RustyYato > How would this work with interior mutability? I.e. would i be able to store a `Cell` in a `const self` field?. Just like how rust deals with interior...
@RustyYato ok this is news to me lmao. I have taken note of that. Yeah, I would have to add a `Freeze` requirement. Thanks for letting me know.
I think theemathas suggestion is nice, and it makes me think about having this syntax. Thoughts? Value only: `const self X: Type = value` place: `static const self Y: OtherType...
If anyone has any issues with how it works now, I am always willing to hear feedback.
@RustyYato The way I could see it work is: if the `const self` field's type implements `Frozen`, you can get a `'static` reference without the fear of undefined behavior. If...
Oh wait, on second thought @RustyYato I remembered why I agreed with @theemathas about this. In Rust, const is fundamentally “value substitution”: it means “copy the value and use it”,...
@RustyYato I believe that this is what it is essentially doing https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=677ae063208965882b18ca507c8e2be8 Since working with `const self` means potentially working with trait objects, the `const { &obj.FIELD }` thing would...
> > > An alternative to this would be that we make existing associated constants object-safe. > > > > > > I did consider going this route at first,...