Take advantage of NestedValue::symbol

This commit is contained in:
Tony Garnock-Jones 2021-08-27 16:59:54 +02:00
parent dc451ea7b4
commit 0aded61071
4 changed files with 9 additions and 11 deletions

View File

@ -454,12 +454,10 @@ fn quote(q: Quote) -> io::Result<()> {
}
fn quote_chunk(q: &Quote, buf: String) -> io::Result<()> {
let v = if let QuotationOutput::Symbol(_) = q.output {
Value::symbol(&buf).wrap()
} else {
Value::String(buf).wrap()
};
output_one(q, &v)
match q.output {
QuotationOutput::Symbol(_) => output_one(q, &IOValue::symbol(&buf)),
_ => output_one(q, &IOValue::new(buf)),
}
}
fn quote_terminated_strings(delimiter: u8, q: &Quote, s: &StringQuotation) -> io::Result<()> {

View File

@ -1,11 +1,11 @@
use crate::value::{IOValue, UnwrappedIOValue, NestedValue};
use crate::value::{IOValue, NestedValue};
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
pub struct Symbol(pub String);
impl serde::Serialize for Symbol {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
UnwrappedIOValue::symbol(&self.0).wrap().serialize(serializer)
IOValue::symbol(&self.0).serialize(serializer)
}
}

View File

@ -746,7 +746,7 @@ impl<N: NestedValue<D>, D: Embeddable> Value<N, D> {
}
pub fn simple_record(label: &str, expected_arity: usize) -> Record<N> {
Self::record(Value::symbol(label).wrap(), expected_arity)
Self::record(N::symbol(label), expected_arity)
}
pub fn simple_record0(label: &str) -> Value<N, D> {

View File

@ -373,7 +373,7 @@ impl<'de, 'src, D: Embeddable, Dec: DomainParse<D>, S: BinarySource<'de>> TextRe
match c {
b'(' | b')' | b'{' | b'}' | b'[' | b']' | b'<' | b'>' |
b'"' | b';' | b',' | b'@' | b'#' | b':' | b'|' | b' ' =>
return Ok(Value::symbol(&decode_utf8(bs)?).wrap()),
return Ok(N::symbol(&decode_utf8(bs)?)),
c => {
self.skip()?;
bs.push(c)
@ -409,7 +409,7 @@ impl<'de, 'src, D: Embeddable, N: NestedValue<D>, Dec: DomainParse<D>, S: Binary
}
b'|' => {
self.skip()?;
Value::symbol(&self.read_string(b'|')?).wrap()
N::symbol(&self.read_string(b'|')?)
}
b';' | b'@' => {
if read_annotations {