use getset::Getters;
#[derive(Clone, Eq, PartialEq, Hash, Debug, Getters)]
pub struct Text {
#[getset(get = "pub")]
question: String,
}
impl Text {
pub fn new(question: impl Into<String>) -> Self {
Self {
question: question.into(),
}
}
}
impl From<&str> for Text {
fn from(question: &str) -> Self {
Self::new(question)
}
}
impl From<String> for Text {
fn from(question: String) -> Self {
Self::new(question)
}
}
#[cfg(test)]
mod tests {
#![allow(clippy::missing_panics_doc)]
use super::*;
#[test]
fn from_a_string_slice_keeps_the_question() {
let question = Text::from("Title");
assert_eq!(question, Text::new("Title"));
}
#[test]
fn trait_send() {
fn assert_send<T: Send>() {}
assert_send::<Text>();
}
#[test]
fn trait_sync() {
fn assert_sync<T: Sync>() {}
assert_sync::<Text>();
}
#[test]
fn trait_unpin() {
fn assert_unpin<T: Unpin>() {}
assert_unpin::<Text>();
}
}