---
source: https://iinventedlight.com/library/notes/rust-functions.md
title: "Rust functions: the fn keyword, snake case, and typed parameters"
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, Functions; The Rust Project Developers, Functions (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-27
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-27
as_of: 2026-11-27
confidence: medium
untested: "Not reproduced (2026-11-27). 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-functions"
tags: [rust, functions, fn, parameters, snake-case]
client: Librarian
sources:
  - id: S1
    title: "Functions"
    publisher: The Rust Project Developers
    url: https://doc.rust-lang.org/book/ch03-03-how-functions-work.html
    accessed: 2026-11-27
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Functions (source)"
    publisher: The Rust Project Developers
    url: https://raw.githubusercontent.com/rust-lang/book/main/src/ch03-03-how-functions-work.md
    accessed: 2026-11-27
    license: "MIT OR Apache-2.0"
---
# Rust functions: the fn keyword, snake case, and typed parameters
**Answer:** Functions are prevalent in Rust code. The fn keyword allows you to declare new functions, and snake case is the conventional style for function and variable names.

## Defining and calling functions

The main function is the entry point of many programs, and fn is the keyword that declares a new function.

Snake case, with all lowercase letters and underscores between words, is the conventional style for function and variable names.

A definition is fn, a name, parentheses, and curly brackets around the body.

You call a function by writing its name and parentheses.

Rust does not care whether a function is defined before or after its caller, only that it is defined in a scope the caller can see.

Lines in main run in the order they appear.

## Parameters

Parameters are special variables that are part of a function's signature.

The concrete values you pass are technically called arguments, though casual talk often uses parameter and argument interchangeably.

Each parameter's type must be declared in the signature, for example x as i32.

That design choice means the compiler almost never needs type annotations elsewhere to know what you mean, and it can give more helpful errors.

When a function has more than one parameter, separate the declarations with commas.

## See also

- [rust-method-syntax](https://iinventedlight.com/library/notes/rust-method-syntax/)
- [rust-advanced-functions](https://iinventedlight.com/library/notes/rust-advanced-functions/)
- [rust-closures](https://iinventedlight.com/library/notes/rust-closures/)

## Claims

- id: C1
  claim: Functions are prevalent in Rust code.
  source: S1
  evidence: "Functions are prevalent in Rust code"

- id: C2
  claim: Function and variable names conventionally use snake case.
  source: S2
  evidence: "Rust code uses _snake case_ as the conventional style"

- id: C3
  claim: Each parameter in a function signature must have a declared type.
  source: S2
  evidence: "you _must_ declare the type of each parameter"

## Sources

- [S1] Functions. The Rust Project Developers. https://doc.rust-lang.org/book/ch03-03-how-functions-work.html . License: MIT OR Apache-2.0. Accessed 2026-11-27.

- [S2] Functions (source). The Rust Project Developers. https://raw.githubusercontent.com/rust-lang/book/main/src/ch03-03-how-functions-work.md . License: MIT OR Apache-2.0. Accessed 2026-11-27.

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, Functions; The Rust Project Developers, Functions (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).
