refactor: use function pointer `fn` instead of a generic `Fn`

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
pull/12759/head
Nik Revenco 2025-06-17 14:58:53 +01:00
parent a2841103a1
commit 6e52d9439f
1 changed files with 11 additions and 11 deletions

View File

@ -5174,6 +5174,16 @@ pub fn completion(cx: &mut Context) {
// comments
/// Perform a `Transaction` to toggle comments
type CommentTransaction = fn(
text: &Rope,
selection: &Selection,
doc_line_token: Option<&str>,
doc_block_tokens: Option<&[BlockCommentToken]>,
syntax: Option<&Syntax>,
loader: &syntax::Loader,
) -> Transaction;
/// Commenting behavior, for each range in selection:
///
/// 1. Only line comment tokens -> line comment
@ -5181,17 +5191,7 @@ pub fn completion(cx: &mut Context) {
/// 3. Whole selection block commented -> uncomment selection
/// 4. All lines not commented and block tokens -> comment uncommented lines
/// 5. No comment tokens and not block commented -> line comment
fn toggle_comments_impl<F>(cx: &mut Context, comments_transaction: F)
where
F: Fn(
&Rope,
&Selection,
Option<&str>,
Option<&[BlockCommentToken]>,
Option<&Syntax>,
&syntax::Loader,
) -> Transaction,
{
fn toggle_comments_impl(cx: &mut Context, comments_transaction: CommentTransaction) {
let (view, doc) = current!(cx.editor);
let syntax = doc.syntax();
let rope = doc.text();