1use alloc::{borrow::Cow, string::String};
12
13#[derive(Clone, Debug, Default, PartialEq, Eq)]
15pub struct IcalBoolean<'a>(pub Cow<'a, str>);
16
17impl IcalBoolean<'_> {
18 pub fn is_true(&self) -> bool {
20 self.0.eq_ignore_ascii_case("TRUE")
21 }
22}
23
24impl<'a> From<&'a str> for IcalBoolean<'a> {
25 fn from(value: &'a str) -> Self {
26 Self(Cow::Borrowed(value))
27 }
28}
29
30impl From<String> for IcalBoolean<'_> {
31 fn from(value: String) -> Self {
32 Self(Cow::Owned(value))
33 }
34}
35
36impl<'a> From<Cow<'a, str>> for IcalBoolean<'a> {
37 fn from(value: Cow<'a, str>) -> Self {
38 Self(value)
39 }
40}
41
42#[cfg(test)]
43mod tests {
44 use crate::value::boolean::IcalBoolean;
45
46 #[test]
47 fn is_true_reads_both_cases() {
48 assert!(IcalBoolean::from("TRUE").is_true());
49 assert!(IcalBoolean::from("true").is_true());
50 assert!(!IcalBoolean::from("FALSE").is_true());
51 assert!(!IcalBoolean::from("false").is_true());
52 }
53}