forked from syndicate-lang/preserves
Value::bytestring, NestedValue::bytestring
This commit is contained in:
parent
0aded61071
commit
f387f5e8c9
|
@ -21,7 +21,7 @@ mod dom {
|
|||
|
||||
fn dom_as_preserves(v: &Dom) -> io::Result<UnwrappedIOValue> {
|
||||
Ok(match v {
|
||||
Dom::One => Value::ByteString(vec![255, 255, 255, 255]),
|
||||
Dom::One => Value::bytestring(vec![255, 255, 255, 255]),
|
||||
Dom::Two => Value::symbol(&format!("Dom::{:?}", v)),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ pub trait NestedValue<D: Embeddable>: Sized + Debug + Clone + Eq + Hash + Ord {
|
|||
Value::symbol(n).wrap()
|
||||
}
|
||||
|
||||
fn bytestring<'a, V: Into<Cow<'a, [u8]>>>(v: V) -> Self {
|
||||
Value::bytestring(v).wrap()
|
||||
}
|
||||
|
||||
fn wrap(anns: Annotations<Self, D>, v: Value<Self, D>) -> Self;
|
||||
|
||||
fn annotations(&self) -> &Annotations<Self, D>;
|
||||
|
@ -655,6 +659,10 @@ impl<N: NestedValue<D>, D: Embeddable> Value<N, D> {
|
|||
self.as_string().ok_or_else(|| self.expected(ExpectedKind::String))
|
||||
}
|
||||
|
||||
pub fn bytestring<'a, V: Into<Cow<'a, [u8]>>>(v: V) -> Self {
|
||||
Value::ByteString(v.into().into_owned())
|
||||
}
|
||||
|
||||
pub fn is_bytestring(&self) -> bool {
|
||||
self.as_bytestring().is_some()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue