scratch_test_value/conversions/to_text.rs
1use std::{borrow::Cow, convert::Infallible};
2
3use crate::{QuirkSink, SValue};
4
5impl SValue {
6 pub fn q_as_text<Q>(&self, _: &mut Q) -> Cow<'_, str>
7 where
8 Q: QuirkSink<Infallible>,
9 {
10 match self {
11 Self::Text(t) => Cow::Borrowed(t),
12 Self::Bool(true) => Cow::Borrowed("true"),
13 Self::Bool(false) => Cow::Borrowed("false"),
14 Self::Int(i) => Cow::Owned(i.to_string()),
15 Self::Float(f) => Cow::Owned(f.to_string()),
16 }
17 }
18}