On Mon, Nov 14, 2022 at 11:03 AM Viresh Kumar viresh.kumar@linaro.org wrote:
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
Ah, I missed that, my bad.
Would it also work in non-mutable way like
let lsettings = line::Settings::new.set_direction(Direction::Output)?;
?