Search code examples
rustintrospection

inspect rust traits at runtime


is there a way to inpect the traits an object provides at runtime. Similar to pythons dir()? I wish to inspect the contents of a core::str::StrSplits<'_> and would like to be able to view the traits it implements.


Solution

  • There is no facility for doing this at runtime; at compile time, however, there is, and this is what rustdoc does.

    With that you can see things like the core::str::StrSplits documentation which covers the information you requested.