simplelog.rs icon indicating copy to clipboard operation
simplelog.rs copied to clipboard

[Suggestion] Make `ConfigBuilder` return itself

Open alexmozaidze opened this issue 3 years ago • 2 comments
trafficstars

There's a thing in Rust called builder pattern which is super convinient to build a struct in-place, ConfigBuilder, however, doesn't do that, it instead needs a mutable reference, can you add methods to construct ConfigBuilder in-place? I also think that reading ConfigBuilder docs is a bit of a pain when every option starts with set_, it makes it harder to read.

alexmozaidze avatar Jan 15 '22 20:01 alexmozaidze

ConfigBuilder's functions should return self, this will be especially convenient to use ConfigBuilder::new().set_time_offset_to_local()

It doesn't need written two extra lines:

let mut builder = ConfigBuilder::new();
builder.set_time_offset_to_local()
... builder ...

imxood avatar May 28 '22 03:05 imxood

Change ConfigBuilder return itself #103

imxood avatar May 28 '22 03:05 imxood