Take advantage of NestedValue::symbol
This commit is contained in:
parent
dc451ea7b4
commit
0aded61071
|
@ -454,12 +454,10 @@ fn quote(q: Quote) -> io::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quote_chunk(q: &Quote, buf: String) -> io::Result<()> {
|
fn quote_chunk(q: &Quote, buf: String) -> io::Result<()> {
|
||||||
let v = if let QuotationOutput::Symbol(_) = q.output {
|
match q.output {
|
||||||
Value::symbol(&buf).wrap()
|
QuotationOutput::Symbol(_) => output_one(q, &IOValue::symbol(&buf)),
|
||||||
} else {
|
_ => output_one(q, &IOValue::new(buf)),
|
||||||
Value::String(buf).wrap()
|
}
|
||||||
};
|
|
||||||
output_one(q, &v)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quote_terminated_strings(delimiter: u8, q: &Quote, s: &StringQuotation) -> io::Result<()> {
|
fn quote_terminated_strings(delimiter: u8, q: &Quote, s: &StringQuotation) -> io::Result<()> {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::value::{IOValue, UnwrappedIOValue, NestedValue};
|
use crate::value::{IOValue, NestedValue};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
||||||
pub struct Symbol(pub String);
|
pub struct Symbol(pub String);
|
||||||
|
|
||||||
impl serde::Serialize for Symbol {
|
impl serde::Serialize for Symbol {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -746,7 +746,7 @@ impl<N: NestedValue<D>, D: Embeddable> Value<N, D> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn simple_record(label: &str, expected_arity: usize) -> Record<N> {
|
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> {
|
pub fn simple_record0(label: &str) -> Value<N, D> {
|
||||||
|
|
|
@ -373,7 +373,7 @@ impl<'de, 'src, D: Embeddable, Dec: DomainParse<D>, S: BinarySource<'de>> TextRe
|
||||||
match c {
|
match c {
|
||||||
b'(' | b')' | b'{' | b'}' | b'[' | b']' | b'<' | b'>' |
|
b'(' | b')' | b'{' | b'}' | b'[' | b']' | b'<' | b'>' |
|
||||||
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 => {
|
c => {
|
||||||
self.skip()?;
|
self.skip()?;
|
||||||
bs.push(c)
|
bs.push(c)
|
||||||
|
@ -409,7 +409,7 @@ impl<'de, 'src, D: Embeddable, N: NestedValue<D>, Dec: DomainParse<D>, S: Binary
|
||||||
}
|
}
|
||||||
b'|' => {
|
b'|' => {
|
||||||
self.skip()?;
|
self.skip()?;
|
||||||
Value::symbol(&self.read_string(b'|')?).wrap()
|
N::symbol(&self.read_string(b'|')?)
|
||||||
}
|
}
|
||||||
b';' | b'@' => {
|
b';' | b'@' => {
|
||||||
if read_annotations {
|
if read_annotations {
|
||||||
|
|
Loading…
Reference in New Issue