Skip to content

Commit e92bd06

Browse files
meta(cursor): Add rule to avoid explicit type annotations (#2717)
I have noticed that Cursor often adds type annotations, especially in `let` statements, even when they are not needed. This typically occurs with generics, which sadly cannot be linted by [clippy::redundant_type_annotations](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_type_annotations), so I have instead decided to add a Cursor rule to hopefully prevent this behavior going forward
1 parent 96f3fcb commit e92bd06

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

.cursor/rules/rust-development.mdc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ alwaysApply: false
2121
- Match existing code style and naming conventions
2222
- Add appropriate logging using `log` crate patterns
2323

24+
## Type Annotations and Inference
25+
26+
- Prefer compiler type inference across the codebase
27+
- Do not add explicit type annotations in `let` bindings or turbofish syntax (e.g., `::<T>`) unless required for the code to compile or to disambiguate an API that inference cannot resolve
28+
- If the code compiles without explicit annotations, omit them
29+
2430
## Development Commands
2531

2632
```bash

0 commit comments

Comments
 (0)