use crate::locale::{English, Locale};
#[derive(Copy, Clone, Debug)]
pub struct ListOptions<L: Locale = English> {
pub(crate) serial_comma: Option<bool>,
pub(crate) conjunction: Option<&'static str>,
pub(crate) locale: L,
}
impl ListOptions<English> {
#[inline]
pub fn new() -> Self {
Self {
serial_comma: None,
conjunction: None,
locale: English,
}
}
}
impl<L: Locale> Default for ListOptions<L> {
#[inline]
fn default() -> Self {
Self {
serial_comma: None,
conjunction: None,
locale: L::default(),
}
}
}
impl<L: Locale> ListOptions<L> {
#[inline]
pub fn serial_comma(mut self) -> Self {
self.serial_comma = Some(true);
self
}
#[inline]
pub fn serial_comma_enabled(mut self, enabled: bool) -> Self {
self.serial_comma = Some(enabled);
self
}
#[inline]
pub fn no_serial_comma(mut self) -> Self {
self.serial_comma = Some(false);
self
}
#[inline]
pub fn conjunction(mut self, word: &'static str) -> Self {
self.conjunction = Some(word);
self
}
#[inline]
pub fn locale<N: Locale>(self, locale: N) -> ListOptions<N> {
ListOptions {
serial_comma: self.serial_comma,
conjunction: self.conjunction,
locale,
}
}
}