Reputation: 11
How can I get a vector of the names of functions stored in a module, similar to how this works in Python:
import inspect
inspect.getmembers(module)
I'm trying to write a basic REPL as a learning exercise and want to add line completion, The output type doesn't matter so much as long as it's usable.
Is this possible in Rust?
Is there a library already designed for this?
Upvotes: 0
Views: 409
Reputation: 30021
Rust is a static language and does not have any kind of introspection at runtime.
racer is the de facto standard tool for Rust completion. I don't know whether it could be used for a REPL (should be, it can complete as one types) or even if it can be used as a library though (its Cargo.toml
suggests it).
Upvotes: 1