---
source: https://iinventedlight.com/library/notes/rust-advanced-functions.md
title: "Rust function pointers: pass fn values and return closures"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (The Rust Project Developers); MIT OR Apache-2.0 (The Rust Project Developers); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Advanced Functions and Closures; The Rust Project Developers, Advanced Functions and Closures (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: rust-advanced-functions"
tags: [rust, function-pointers, fn, closures, ffi]
client: Librarian
sources:
  - id: S1
    title: "Advanced Functions and Closures"
    publisher: The Rust Project Developers
    url: https://doc.rust-lang.org/book/ch20-04-advanced-functions-and-closures.html
    accessed: 2026-11-26
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Advanced Functions and Closures (source)"
    publisher: The Rust Project Developers
    url: https://raw.githubusercontent.com/rust-lang/book/main/src/ch20-04-advanced-functions-and-closures.md
    accessed: 2026-11-26
    license: "MIT OR Apache-2.0"
---
# Rust function pointers: pass fn values and return closures
**Answer:** This section explores advanced features related to functions and closures, including function pointers and returning closures.

## Function pointers

The chapter covers advanced features of functions and closures, including function pointers and returning closures.

You can pass regular functions to functions, not only closures.

The fn type is called a function pointer, with a lowercase f, and should not be confused with the Fn closure trait.

Passing functions this way lets you use functions as arguments.

In the book's example, do_twice takes a function pointer and an i32, calls the function twice, and adds the results, so passing add_one prints The answer is: 12.

Unlike closures, fn is a type rather than a trait, so you name fn as the parameter type directly instead of introducing a generic type with an Fn bound.

Function pointers implement all three closure traits, Fn, FnMut, and FnOnce, so you can always pass a function pointer where a closure is expected.

Prefer a generic function with a closure trait so it can accept a closure or a function.

Accept only fn, not closures, when talking to external code without closures; C can accept functions as arguments and does not have closures.

## See also

- [rust-closures](https://iinventedlight.com/library/notes/rust-closures/)
- [rust-impl-trait](https://iinventedlight.com/library/notes/rust-impl-trait/)
- [rust-advanced-types](https://iinventedlight.com/library/notes/rust-advanced-types/)

## Claims

- id: C1
  claim: The fn type is a function pointer and is not the same as the Fn closure trait.
  source: S1
  evidence: "The fn type is called a function pointer"

- id: C2
  claim: Function pointers implement Fn, FnMut, and FnOnce, so they can be passed where a closure is expected.
  source: S1
  evidence: "Function pointers implement all three of the closure traits"

- id: C3
  claim: Accepting only fn is useful when calling C functions, because C has no closures.
  source: S2
  evidence: "C functions can accept functions as arguments, but C doesn't have closures."

## Sources

- [S1] Advanced Functions and Closures. The Rust Project Developers. https://doc.rust-lang.org/book/ch20-04-advanced-functions-and-closures.html . License: MIT OR Apache-2.0. Accessed 2026-11-26.

- [S2] Advanced Functions and Closures (source). The Rust Project Developers. https://raw.githubusercontent.com/rust-lang/book/main/src/ch20-04-advanced-functions-and-closures.md . License: MIT OR Apache-2.0. Accessed 2026-11-26.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Advanced Functions and Closures; The Rust Project Developers, Advanced Functions and Closures (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
