Skip to content

(fun)

function declarations

clojure
(fun name? args?)

Where:

  1. name: function name *
  2. args: parameters supplied to the function *

Matching:

  1. functions, e.g. fn foo() {}
  2. async functions, e.g. async fn foo() {}

Behavior

  • Matches function declarations, not closures.

Examples

Find entry-point functions across a crate.

clojure
(fun (id main))

Selects in lines { 1 } but not in { 2 }:

rust
fn main() {}
fn main_loop() {}

Find functions that expect a ctx parameter first.

clojure
(fun _ (arg 1 (id ctx)))

Selects in lines { 1 } but not in { 2 }:

rust
fn handle(ctx: &Context, req: Request) {}
fn render(req: Request) {}

Arguments

name

• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
(id)
(:into) (:and) (:or) (:not) (:text) (:kind) (:replace) (:capture)

args

(arg)
(:into) (:and) (:or) (:not) (:text) (:kind) (:replace) (:capture)

Copyright © 2022-present Semantic Works, Inc.