Re: [libgpiod][PATCH 15/16] bindings: rust: make mutators return &mut self

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16-01-23, 13:57, Bartosz Golaszewski wrote:
> 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.

What you did earlier is the easiest way to get around it probably.
i.e. use config.request().reconfigure_lines().

-- 
viresh



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux