# Idea: Experimental attribute based support for partial borrows

**URL:** <https://internals.rust-lang.org/t/idea-experimental-attribute-based-support-for-partial-borrows/20744>\
**Category:** language design\
**Created:** [April 29, 2024, 4:40pm UTC](https://internals.rust-lang.org/t/idea-experimental-attribute-based-support-for-partial-borrows/20744 "2024-04-29T16:40:11Z")\
**Posts on this page:** 1\
**Showing post:** 29

<div class="post-metadata">

**Author:** ![mathstuf](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mathstuf](https://internals.rust-lang.org/u/mathstuf)\
**Post date:** [May 4, 2024, 10:27am UTC](https://internals.rust-lang.org/t/idea-experimental-attribute-based-support-for-partial-borrows/20744/29 "2024-05-04T10:27:46Z")

</div>

Ah, I think I have an interesting use case here: declaring a partial borrow _without actually using the member_. See [this MR](https://gitlab.kitware.com/utils/ghostflow-director/-/merge_requests/357) (though in particular [this commit](https://gitlab.kitware.com/utils/ghostflow-director/-/merge_requests/357/diffs?commit_id=f6eb477ca2e8f0f6a34f97dfdfadf71ee7a67011)). Here, the highlighted commit, instead of making a new type, may have been able to utilize partial borrowing to declare that using the `writer` is a conceptual `&mut` borrow of `data` even though there is no method that uses both syntactically. The point is that even though `data` is not mentioned, it _must be considered borrowed in order to avoid a deadlock_ because the _receiving_ end of `writer` needs a write lock on the `RwLock<data::Data>` to actually consume items from the channel.

To me, this means that there must be a way to explicitly list members that are considered borrowed even if there is support for implicit computation because there may be safety considerations in how members are grouped into types (not that this example is one of Rust safety/soundness guarantees given that the deadlock behavior is Rust-safe, but someone can probably craft such an example).

---

_[View the full topic](https://internals.rust-lang.org/t/idea-experimental-attribute-based-support-for-partial-borrows/20744)._
