pub enum OwnedSexpr {
List(OwnedSexprs),
Group(OwnedSexprs),
String(Vec<u8>),
Atom(Vec<u8>),
Comment(Vec<u8>),
}
Expand description
An owned version of Sexpr
. You can convert to and from Sexpr
using the From
trait.
§Display
OwnedSexpr
implements the Display
trait for serializing to strings. By default, the output
will try to minimize the amount of spaces used and the resulting output will be on one line.
Enabling the formatter’s alternate
flag using #
, causes the output to be human-friendly /
pretty-printed. Setting the precision
with .
additionally allows to specify the number of
spaces used for indentation (2 by default).
For example:
let sexpr = rsexpr::from_slice(b"[ a b c ]").unwrap();
assert_eq!(format!("{sexpr}"), "[a b c]");
assert_eq!(format!("{sexpr:#}"), "[
a
b
c
]");
assert_eq!(format!("{sexpr:#.4}"), "[
a
b
c
]");
Variants§
List(OwnedSexprs)
A list of OwnedSexpr
s surrounded by parentheses (
, )
Group(OwnedSexprs)
A list of OwnedSexpr
s surrounded by brackets [
, ]
String(Vec<u8>)
A sequence of bytes surrounded by quotes "
Atom(Vec<u8>)
A sequence of bytes not including whitespace, parens, and quotes
Comment(Vec<u8>)
Available on crate feature
comments
only.A line comment, including the leading ;
Implementations§
Source§impl OwnedSexpr
impl OwnedSexpr
Sourcepub fn unwrap_list(self) -> OwnedSexprs
pub fn unwrap_list(self) -> OwnedSexprs
Sourcepub fn unwrap_list_ref(&self) -> &OwnedSexprs
pub fn unwrap_list_ref(&self) -> &OwnedSexprs
Sourcepub fn unwrap_group(self) -> OwnedSexprs
pub fn unwrap_group(self) -> OwnedSexprs
Sourcepub fn unwrap_group_ref(&self) -> &OwnedSexprs
pub fn unwrap_group_ref(&self) -> &OwnedSexprs
Sourcepub fn unwrap_string(self) -> Vec<u8> ⓘ
pub fn unwrap_string(self) -> Vec<u8> ⓘ
Sourcepub fn unwrap_string_ref(&self) -> &Vec<u8> ⓘ
pub fn unwrap_string_ref(&self) -> &Vec<u8> ⓘ
Sourcepub fn unwrap_atom(self) -> Vec<u8> ⓘ
pub fn unwrap_atom(self) -> Vec<u8> ⓘ
Trait Implementations§
Source§impl Clone for OwnedSexpr
impl Clone for OwnedSexpr
Source§fn clone(&self) -> OwnedSexpr
fn clone(&self) -> OwnedSexpr
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for OwnedSexpr
impl Debug for OwnedSexpr
Source§impl Display for OwnedSexpr
impl Display for OwnedSexpr
Source§impl<'a> From<&'a OwnedSexpr> for Sexpr<'a>
impl<'a> From<&'a OwnedSexpr> for Sexpr<'a>
Source§fn from(value: &'a OwnedSexpr) -> Self
fn from(value: &'a OwnedSexpr) -> Self
Converts to this type from the input type.
Source§impl From<Sexpr<'_>> for OwnedSexpr
impl From<Sexpr<'_>> for OwnedSexpr
Source§impl FromIterator<OwnedSexpr> for OwnedSexprs
impl FromIterator<OwnedSexpr> for OwnedSexprs
Source§fn from_iter<T: IntoIterator<Item = OwnedSexpr>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = OwnedSexpr>>(iter: T) -> Self
Creates a value from an iterator. Read more
Source§impl Hash for OwnedSexpr
impl Hash for OwnedSexpr
Source§impl PartialEq for OwnedSexpr
impl PartialEq for OwnedSexpr
impl Eq for OwnedSexpr
impl StructuralPartialEq for OwnedSexpr
Auto Trait Implementations§
impl Freeze for OwnedSexpr
impl RefUnwindSafe for OwnedSexpr
impl Send for OwnedSexpr
impl Sync for OwnedSexpr
impl Unpin for OwnedSexpr
impl UnwindSafe for OwnedSexpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more