Enum OwnedSexpr

Source
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 OwnedSexprs surrounded by parentheses (, )

§

Group(OwnedSexprs)

A list of OwnedSexprs 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

Source

pub fn unwrap_list(self) -> OwnedSexprs

Returns the contained List value, consuming self.

§Panics

Panics if self is not List.

Source

pub fn unwrap_list_ref(&self) -> &OwnedSexprs

Returns the contained List value by reference.

§Panics

Panics if self is not List.

Source

pub fn unwrap_group(self) -> OwnedSexprs

Returns the contained Group value, consuming self.

§Panics

Panics if self is not Group.

Source

pub fn unwrap_group_ref(&self) -> &OwnedSexprs

Returns the contained Group value by reference.

§Panics

Panics if self is not Group.

Source

pub fn unwrap_string(self) -> Vec<u8>

Returns the contained String value, consuming self.

§Panics

Panics if self is not String.

Source

pub fn unwrap_string_ref(&self) -> &Vec<u8>

Returns the contained String value by reference.

§Panics

Panics if self is not String.

Source

pub fn unwrap_atom(self) -> Vec<u8>

Returns the contained Atom value, consuming self.

§Panics

Panics if self is not Atom.

Source

pub fn unwrap_atom_ref(&self) -> &Vec<u8>

Returns the contained Atom value by reference.

§Panics

Panics if self is not Atom.

Trait Implementations§

Source§

impl Clone for OwnedSexpr

Source§

fn clone(&self) -> OwnedSexpr

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OwnedSexpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for OwnedSexpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a OwnedSexpr> for Sexpr<'a>

Source§

fn from(value: &'a OwnedSexpr) -> Self

Converts to this type from the input type.
Source§

impl From<Sexpr<'_>> for OwnedSexpr

Source§

fn from(value: Sexpr<'_>) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<OwnedSexpr> for OwnedSexprs

Source§

fn from_iter<T: IntoIterator<Item = OwnedSexpr>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for OwnedSexpr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for OwnedSexpr

Source§

fn eq(&self, other: &OwnedSexpr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for OwnedSexpr

Source§

impl StructuralPartialEq for OwnedSexpr

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.