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
use crate::types::list::{List, ListItem}; #[derive(Clone, Debug, Default)] pub struct ListBuilder { items: Vec<ListItem>, } impl ListBuilder { pub fn new() -> Self { Self::default() } #[deprecated(note = "Please use the `append` function instead.", since = "0.3.0")] pub fn add(mut self, item: impl Into<ListItem>) -> Self { self.items.push(item.into()); self } pub fn append(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() } }