You are viewing a single thread.
View all comments
1 point

So rust finally gets reflection? In stable no less!

permalink
report
reply
2 points

@bwrsandman @snaggen More a RTTI than reflection…

permalink
report
parent
reply
1 point

Isn’t RTTI for polymorphic classes and stored in (or around) vtables?

permalink
report
parent
reply
2 points

@bwrsandman That’s why I used ”More a” than ”Is a”… 😉

permalink
report
parent
reply
1 point

Unfortunately, it’s not guaranteed to be the same string all the time, so it’s rather useless for anything but debugging and logging.

permalink
report
parent
reply
15 points

Well, if the only thing you need from reflection is the name of a type, so then yes. But I wouldn’t really call this reflection since it is very limited.

permalink
report
parent
reply
9 points

Yeah, Rust can’t have proper reflection, since there’s no external runtime environment that keeps track of your state. Any such smartness either has to be compiled-in (which is how std::any and macros work) or you can implement something to keep track of this state at runtime, as if you were partially building a runtime environment.

permalink
report
parent
reply
12 points

Minor point of clarification: it can’t have runtime reflection, but in principle it could have compile time reflection.

permalink
report
parent
reply

Rust

!rust@programming.dev

Create post

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits
  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

Community stats

  • 572

    Monthly active users

  • 812

    Posts

  • 3.7K

    Comments