Skip to main content

codefold_core/
options.rs

1use crate::Level;
2
3/// Options for `read_opts`.
4#[derive(Debug, Clone)]
5pub struct Options {
6    pub level: Level,
7    /// When non-empty, every function/method/class whose name appears here is
8    /// rendered with its body kept in full, regardless of the base `level`.
9    /// A class name in this list expands to "every method of that class".
10    pub focus: Vec<String>,
11}
12
13impl Options {
14    pub fn new(level: Level) -> Self {
15        Self {
16            level,
17            focus: Vec::new(),
18        }
19    }
20
21    pub fn focus<I, S>(mut self, names: I) -> Self
22    where
23        I: IntoIterator<Item = S>,
24        S: Into<String>,
25    {
26        self.focus = names.into_iter().map(Into::into).collect();
27        self
28    }
29}