On Mon, Jan 16, 2023 at 10:41 AM Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote: > > On 16-01-23, 09:42, Bartosz Golaszewski wrote: > > On Mon, Jan 16, 2023 at 7:02 AM Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote: > > > > > > On 13-01-23, 22:52, Bartosz Golaszewski wrote: > > > > diff --git a/bindings/rust/libgpiod/tests/line_request.rs b/bindings/rust/libgpiod/tests/line_request.rs > > > > index c3fc37b..561f4e8 100644 > > > > --- a/bindings/rust/libgpiod/tests/line_request.rs > > > > +++ b/bindings/rust/libgpiod/tests/line_request.rs > > > > @@ -97,13 +97,11 @@ mod line_request { > > > > config.lconfig_add_settings(&offsets); > > > > config.request_lines().unwrap(); > > > > > > > > - let request = config.request(); > > > > - > > > > > > Why remove this ? And open-code it ? > > > > > > > Because I'm a Rust noob and couldn't figure out how to deal with the > > mutable/non-mutable borrow vomit that ensued when I kept the local > > variable. If you could improve upon this one, it would be great! > > From what I can understand, config.request() returns a mutable > reference and you don't need a mutable variable to keep it, since the > variable doesn't need to store another reference later. Just moving > back to original code should work here. > Seems like I went overboard with converting all of those cases but in same places this still fails: error[E0502]: cannot borrow `config` as immutable because it is also borrowed as mutable --> libgpiod/tests/line_request.rs:449:24 | 441 | let request = config.request(); | ---------------- mutable borrow occurs here ... 449 | let info = config.chip().line_info(0).unwrap(); | ^^^^^^^^^^^^^ immutable borrow occurs here ... 456 | request.reconfigure_lines(&lconfig).unwrap(); | ----------------------------------- mutable borrow later used here If I make config.chip() return &mut Chip then it fails like that: error[E0499]: cannot borrow `config` as mutable more than once at a time --> libgpiod/tests/line_request.rs:449:24 | 441 | let request = config.request(); | ---------------- first mutable borrow occurs here ... 449 | let info = config.chip().line_info(0).unwrap(); | ^^^^^^^^^^^^^ second mutable borrow occurs here ... 456 | request.reconfigure_lines(&lconfig).unwrap(); | ----------------------------------- first borrow later used here Not sure how to go about this. Bart