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
use crate::types::list::{List, ListItem}; #[derive(Clone, Debug, Default)] pub struct ListBuilder { items: Vec<ListItem>, } impl ListBuilder { pub fn new() -> Self { Self::default() } pub fn add(mut self, item: impl Into<ListItem>) -> Self { self.items.push(item.into()); self } pub fn ordered(self) -> List { List::ordered_with(self.items) } pub fn unordered(self) -> List { List::unordered_with(self.items) } } impl List { pub fn builder() -> ListBuilder { ListBuilder::new() } }