-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathopt.rs
More file actions
38 lines (33 loc) · 961 Bytes
/
Copy pathopt.rs
File metadata and controls
38 lines (33 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use derive_builder::Builder;
#[derive(Builder, Debug, Default, PartialEq, Eq, Hash, Clone)]
#[builder(derive(Debug, PartialEq, Eq, Hash))]
#[builder(build_fn(private, name = "fallible_build"))]
pub struct RenderOptions {
// The initial header level
#[builder(default = 0)]
pub initial_header_level: u8,
/// Produce a standalone document
#[builder(default = true)]
pub standalone: bool,
}
impl RenderOptionsBuilder {
pub fn build(&mut self) -> RenderOptions {
self.fallible_build()
.expect("All required fields set at initialization")
}
}
impl From<bool> for RenderOptions {
fn from(standalone: bool) -> Self {
RenderOptionsBuilder::default()
.standalone(standalone)
.build()
}
}
#[cfg(test)]
mod tests {
use super::RenderOptionsBuilder;
#[test]
fn no_required_fields_added_to_render_options() {
RenderOptionsBuilder::default().build();
}
}