rust_texas/document/
package.rs

1use crate::prelude::*;
2
3/// This here is the main reason I made this crate - other crates don't let you add options
4/// to packages. Has macro support, so please use it :).
5#[derive(Debug, Clone)]
6pub struct Package {
7    pub(crate) name: String,
8    pub(crate) opt: Vec<String>,
9}
10impl AsLatex for Package {
11    fn to_string(&self) -> String {
12        let options = self
13            .opt
14            .iter()
15            .map(|s| format!("{}, ", s))
16            .collect::<String>();
17        format!("\\usepackage[{}]{{{}}}\n", options, self.name)
18    }
19}
20impl Opt for Package {
21    fn add_option(&mut self, opt: &str) {
22        self.opt.push(opt.to_string())
23    }
24}
25impl Package {
26    pub fn new(name: &str) -> Self {
27        Self {
28            name: name.to_string(),
29            opt: vec![],
30        }
31    }
32}