use getset::Getters;
#[derive(Clone, Eq, PartialEq, Hash, Debug, Getters)]
pub struct Select {
#[getset(get = "pub")]
question: String,
#[getset(get = "pub")]
options: Vec<String>,
}
impl Select {
pub fn new(
question: impl Into<String>,
options: impl IntoIterator<Item = impl Into<String>>,
) -> Self {
Self {
question: question.into(),
options: options.into_iter().map(Into::into).collect(),
}
}
}
#[cfg(test)]
mod tests {
#![allow(clippy::missing_panics_doc)]
use super::*;
#[test]
fn new_keeps_the_options_in_their_order() {
let question = Select::new("Kind of change", ["Added", "Fixed"]);
assert_eq!(
question.options(),
&vec!["Added".to_owned(), "Fixed".to_owned()]
);
}
#[test]
fn trait_send() {
fn assert_send<T: Send>() {}
assert_send::<Select>();
}
#[test]
fn trait_sync() {
fn assert_sync<T: Sync>() {}
assert_sync::<Select>();
}
#[test]
fn trait_unpin() {
fn assert_unpin<T: Unpin>() {}
assert_unpin::<Select>();
}
}