Radar · Rust · Archive · Week 28 · Jul 6 – 12, 2026
Named `Fn` trait parameters (RFC 3955)
Nice to knowlanguage
- What changed
- The RFC was merged, allowing optional named function parameters in parenthesized generic argument lists for
Fn,FnMut,FnOnce,AsyncFn,AsyncFnMut, andAsyncFnOnce. - Production impact
- The source does not say.
- Try it
- On a nightly compiler, write a function that takes
impl Fn(msg: String, priority: usize)and observe that the names are accepted but ignored. - Source
- github.com/rust-lang/rfcs/pull/3955
Understand it, then run it
Rust now lets you write names for the parameters of Fn‑like traits in the same way you can for function pointers. Before the change you could only write impl Fn(String, usize) or impl FnOnce(&str). With the new syntax you can write impl Fn(msg: String, priority: usize) and the names are ignored by the compiler. The names are only for documentation and tooling; they do not change how the function works.
Run it now
// This program demonstrates the current syntax for `Fn` trait parameters
// in Rust 1.98.1 (edition 2024). Named parameters are not yet supported,
// so we use the standard `impl Fn(String, usize)` syntax.
fn main() {
// Define a logger that prints the message and priority.
let logger = |msg: String, priority: usize| {
println!("[{}] {}", priority, msg);
};
// Call the function that uses the logger.
log_message("Hello, world!", logger);
}
// The `log_message` function accepts any closure that implements
// `Fn(String, usize)`. The closure is invoked with a message and a priority.
fn log_message(message: &str, log: impl Fn(String, usize)) {
// Convert the message to a String and call the logger with priority 1.
log(message.to_string(), 1);
}
What it printed when we ran it on Rust 1.98.1 (edition 2024)
[1] Hello, world!
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed