summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrotzeit <brotzeitmacher@gmail.com>2021-11-27 17:57:33 +0100
committerbrotzeit <brotzeitmacher@gmail.com>2021-11-27 17:57:33 +0100
commit5cf4207916a54a711c16351719dddc8f1b4e2d48 (patch)
treec3ab97d5db235136e9e2abd2c7e05fe6f0800fd7
parent63ea805a19cfefccb7fd047b418ad743680c2f2d (diff)
downloadrust-mode-5cf4207916a54a711c16351719dddc8f1b4e2d48.tar.gz
copy command rustic-toggle-mutability from #194
-rw-r--r--rust-utils.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/rust-utils.el b/rust-utils.el
index 022973b..d44a609 100644
--- a/rust-utils.el
+++ b/rust-utils.el
@@ -77,6 +77,15 @@ visit the new file."
(delete-pair))
(t (rust-insert-dbg)))))))
+(defun rustic-toggle-mutability ()
+ "Toggles the mutability of the variable defined on the current line"
+ (interactive)
+ (save-excursion
+ (back-to-indentation)
+ (forward-word)
+ (if (string= " mut" (buffer-substring (point) (+ (point) 4)))
+ (delete-region (point) (+ (point) 4))
+ (insert " mut"))))
;;; _
(provide 'rust-utils)
;;; rust-utils.el ends here