user6501841
user6501841

Reputation: 11

Find function names in a module

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.

  1. Is this possible in Rust?

  2. Is there a library already designed for this?

Upvotes: 0

Views: 409

Answers (1)

mcarton
mcarton

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

Related Questions