---
title: "Rust pattern: Precise closure capture clauses · baby steps"
url: https://daily.dev/posts/rust-pattern-precise-closure-capture-clauses-baby-steps-ki1cebrvd
source_url: https://smallcultfollowing.com/babysteps/blog/2018/04/24/rust-pattern-precise-closure-capture-clauses
type: article
source: "Niko Matsakis - baby steps"
published: 2026-05-31T07:54:17.574Z
updated: 2026-05-31T09:02:53.420Z
tags: ["rust"]
reading_time: 7
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust pattern: Precise closure capture clauses · baby steps

**[Niko Matsakis - baby steps](https://daily.dev/sources/babysteps)** · 7 min read · 0 upvotes · 0 comments

## Summary

Rust closures capture entire local variables rather than individual fields, which can cause borrow checker conflicts when a closure captures `self` but only uses one field while another field is mutably borrowed. The fix is to introduce a local variable referencing only the needed field before the closure, so the closure captures that variable instead of all of `self`. A more explicit pattern uses a block with `let` bindings followed by a `move` closure, giving precise control over what is captured and how — analogous to C++ capture clauses. RFC #2229 aims to eventually allow closures to capture individual struct paths rather than whole variables.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://smallcultfollowing.com/babysteps/blog/2018/04/24/rust-pattern-precise-closure-capture-clauses>

## Similar posts on daily.dev

- [Rust's Block Pattern](https://daily.dev/posts/rust-s-block-pattern-qtpupzlmb) · notgull · 9 upvotes · 0 comments

---

Tags: [#rust](https://daily.dev/tags/rust)

[View this post on daily.dev](https://daily.dev/posts/rust-pattern-precise-closure-capture-clauses-baby-steps-ki1cebrvd)
