Re: [libgpiod][PATCH V9 6/8] bindings: rust: Add examples to libgpiod crate

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

 



On 10-11-22, 19:26, Bartosz Golaszewski wrote:
> I'm looking at it and thinking that it would look much better as:
> 
> let settings = line::Settings::new()
>     .set_direction(Direction::Output)
>     .set_output_value(Value::new(value))
>     .build()?;
> 
> settings would not need to be mutable (we'd have some intermediate
> SettingsBuilder object?) and could be directly passed to
> add_line_settings()?
> 
> We now have chained mutators for LineSettings in C++ and keyword
> arguments in Python - somehow I think that the former suits rust much
> better than passing an array of properties.

We already support chained mutators in the Rust bindings. This example can also
be written as:

         let mut lsettings = line::Settings::new()?;
 
         lsettings
             .set_direction(Direction::Output)?
             .set_output_value(Value::new(value)?)?;
 
-- 
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