clawless_core/prompt/
text.rs1use getset::Getters;
2
3#[derive(Clone, Eq, PartialEq, Hash, Debug, Getters)]
18pub struct Text {
19 #[getset(get = "pub")]
21 question: String,
22}
23
24impl Text {
25 pub fn new(question: impl Into<String>) -> Self {
35 Self {
36 question: question.into(),
37 }
38 }
39}
40
41impl From<&str> for Text {
42 fn from(question: &str) -> Self {
43 Self::new(question)
44 }
45}
46
47impl From<String> for Text {
48 fn from(question: String) -> Self {
49 Self::new(question)
50 }
51}
52
53#[cfg(test)]
54mod tests {
55 #![allow(clippy::missing_panics_doc)]
58
59 use super::*;
60
61 #[test]
62 fn from_a_string_slice_keeps_the_question() {
63 let question = Text::from("Title");
64
65 assert_eq!(question, Text::new("Title"));
66 }
67
68 #[test]
69 fn trait_send() {
70 fn assert_send<T: Send>() {}
71 assert_send::<Text>();
72 }
73
74 #[test]
75 fn trait_sync() {
76 fn assert_sync<T: Sync>() {}
77 assert_sync::<Text>();
78 }
79
80 #[test]
81 fn trait_unpin() {
82 fn assert_unpin<T: Unpin>() {}
83 assert_unpin::<Text>();
84 }
85}