← ClaudeAtlas

rust-analyzer-ssrlisted

Use rust-analyzer's Structural Search and Replace (SSR) to change lots of Rust code. SSR matches by AST structure and semantic meaning, understanding type resolution and path equivalence.
paulnsorensen/hallouminate · ★ 0 · AI & Automation · score 66
Install: claude install-skill paulnsorensen/hallouminate
# rust-analyzer Structural Search and Replace (SSR) Use rust-analyzer's SSR for semantic code transformations in Rust projects. SSR matches code by AST structure and semantic meaning, not text. ## When to Use - Refactoring patterns across a codebase (rename, restructure, migrate APIs) - Converting between equivalent forms (UFCS to method calls, struct literals to constructors) - Finding all usages of a specific code pattern - Semantic-aware search that understands type resolution ## Basic Syntax ``` <search_pattern> ==>> <replacement_pattern> ``` Placeholders capture matched code: - `$name` — matches any expression/type/pattern in that position - `${name:constraint}` — matches with constraints ## Common Patterns ### Swap function arguments ``` foo($a, $b) ==>> foo($b, $a) ``` ### Convert struct literal to constructor ``` Foo { a: $a, b: $b } ==>> Foo::new($a, $b) ``` ### UFCS to method call ``` Foo::method($receiver, $arg) ==>> $receiver.method($arg) ``` ### Method to UFCS ``` $receiver.method($arg) ==>> Foo::method($receiver, $arg) ``` ### Wrap in Result ``` Option<$t> ==>> Result<$t, Error> ``` ### Unwrap to expect ``` $e.unwrap() ==>> $e.expect("TODO") ``` ### Match only literals ``` Some(${a:kind(literal)}) ==>> ... ``` ### Match non-literals ``` Some(${a:not(kind(literal))}) ==>> ... ``` ## Constraints | Constraint | Matches | |------------|---------| | `kind(literal)` | Literal values: `42`, `"foo"`, `true` | | `not(...)` | Negates inner constraint | #