toasty_core/stmt/
value_list.rs1use crate::stmt::Value;
4
5impl Value {
6 pub fn list_from_vec(items: Vec<Self>) -> Self {
16 Self::List(items)
17 }
18
19 pub fn is_list(&self) -> bool {
21 matches!(self, Self::List(_))
22 }
23
24 #[track_caller]
31 pub fn into_list_unwrap(self) -> Vec<Value> {
32 match self {
33 Value::List(list) => list,
34 _ => panic!("expected Value::List; actual={self:#?}"),
35 }
36 }
37}
38
39impl From<Vec<Value>> for Value {
40 fn from(value: Vec<Value>) -> Self {
41 Value::List(value)
42 }
43}
44
45impl<T, const N: usize> PartialEq<[T; N]> for Value
46where
47 T: PartialEq<Value>,
48{
49 fn eq(&self, other: &[T; N]) -> bool {
50 match self {
51 Value::List(items) => items.iter().enumerate().all(|(i, item)| other[i].eq(item)),
52 _ => false,
53 }
54 }
55}
56
57impl<T, const N: usize> PartialEq<Value> for [T; N]
58where
59 T: PartialEq<Value>,
60{
61 fn eq(&self, other: &Value) -> bool {
62 other.eq(self)
63 }
64}