Byron / Byron/pulldown-cmark-to-cmark
Idea: consider using "builder pattern" for `Options` struct to prevent breaking changes in additions
- Dominant language
- Rust
- Stars
- 63
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
I think it might be valuable to consider using "builder pattern" for the `Options` struct (and perhaps `State` as well) to prevent breaking changes in additions (e.g. #17). It would mean you could easily add more options to these structs without it being a breaking change because all fields would be private for `Options`.
See https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
### Example (consuming builder)
API:
```rust
let options = Options::default()
.newlines_after_headline(2)
.newlines_after_paragraph(3);
```
Implementation
```rust
struct Options {
newlines_after_headline: usize,
newlines_after_paragraph: usize,
..
}
impl Options {
fn newlines_after_headline(mut self, value: usize) -> Self {
self.newlines_after_headline = value;
self
}
fn newlines_after_paragraph(mut self, value: usize) -> Self {
self.newlines_after_paragraph = value;
self
}
..
}
```
Contributor guide
Assessment
This issue has not been assessed yet.