Working with a syn::Path of nested types (eg Option>)

⚓ Rust    📅 2026-06-18    👤 surdeus    👁️ 1      

surdeus

Before I try to solve this myself, it feels like a problem which probably already has a good solution in a crate somewhere.... Does anyone know of a crate that helps with the following?:

I want to manipulate nested types in a Path, as part of a proc_macro

E.g. if I have parsed Option<Box<Foo>> as a syn::Path I would like to:

  • iterate into it getting: Option<Box<Foo>>, Box<Foo>, Foo
  • update the innermost type to give Option<Box<Bar>>

This could get arbitrarily complicated when associated types (nice to have) and types with multiple generics (need) come into play.

3 posts - 2 participants

Read full topic

🏷️ Rust_feed