Remove unnecessary borrow_parts() methods
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 16 Jan 2020 18:48:16 +0000 (10:48 -0800)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 16 Jan 2020 18:48:16 +0000 (10:48 -0800)
commite58440fe454653cedab465c495e39881fbc74aab
tree082dbf4c881ccd213929a0447c70017c7fecfe5a
parenta252f81477c25bf1248fd9ea5269a6620187c487
Remove unnecessary borrow_parts() methods

Accessing a struct through an std::syn::MutexGuard using implicit
dereferencing can confuse the borrow checker. This situation arises when
obtaining mutable references to more than one field of the struct, which
is normally allowed.

https://doc.rust-lang.org/nomicon/borrow-splitting.html

However, when using implicit dereferencing, a mutable reference to the
the entire struct is taken. Thus, attempting to access another field in
this manner will lead to a compilation error.

https://doc.rust-lang.org/error-index.html#E0499

A simple way to avoid this is to first obtain a mutable reference to the
struct using explicit dereferencing.
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/peer_handler.rs
lightning/src/ln/router.rs