Using `rust-analyzer` to examine trait method signatures outside of IDE

Is there a way to use rust-analyzer to iterate over the method signatures of a trait outside the context of an IDE?

More info:
Given a procedural macro that produces some type with a non-pub interior iterator, is it possible to iterate over the signatures of the core::iter::Iterator provided methods so that I can generate convenience methods for my struct with the same names?

  1. Ideally, the user should be able to call something like MyCoolStruct::step_by or MyCoolStruct::collect with the same parameters they'd provide were they able to access the inner iterator and use its iterator directly.
  2. Unfortunately, I cannot provide access to the inner iterator while maintaining the guarantees I'd like to enforce with this library.

If anyone knows where I could look in the ra documentation, it would be helpful, but I thought I'd ask if anyone has encountered something similar. Thank you.

rust-analyzer is available as a library (or rather, multiple libraries) however the API is unstable and documentation is often missing (feel free to drop to Zulip or GitHub and ask, though!)

The rust-analyzer crates are prefixed with ra_ap_ and are all the crates available here. However, the crates you are likely to interface with are: load-cargo, which is used to load a Cargo project, syntax, which is the AST, hir, which is the main (relatively stable) interface to analysis, and ide-db, which declares the database, represents changes to the analyzed code, and define various analysis helpers.

1 Like