We need to parse the rust code, may be represented by an AST(Abstract Syntax Tree)
Please try to find other tools/parsers and how can we achieve this
You can start with this stackoverflow answer:
https://stackoverflow.com/questions/26575443/how-do-i-use-the-rust-parser-libsyntax-myself