[−][src]Struct lexpr::Datum
Combines an S-expression value with location information.
A Datum keeps, along with a plain Value, information about the text
location the value was parsed from. For compound values, such as lists and
vectors, that includes information for all contained values, recursively.
A Datum can be obtained by using the parse_datum and expect_datum
methods on Parser.
Methods
impl Datum[src]
pub fn value(&self) -> &Value[src]
Returns a reference to the contained value.
pub fn span(&self) -> Span[src]
Returns the span for the compelete value.
pub fn as_ref(&self) -> Ref[src]
Returns a reference to the datum.
pub fn list_iter(&self) -> Option<ListIter>[src]
Returns an iterator over the elements of a list.
If the value contained in the datum is not either a cons cell or Null, None is
returned.
Note that the returned iterator has special behavior for improper lists, yielding the
element after the dot after returning None the first time.
use lexpr::sexp; let datum = lexpr::datum::from_str("(1 2 . 3)").unwrap(); let mut iter = datum.list_iter().unwrap(); let one = iter.next().unwrap(); assert_eq!(one.value(), &sexp!(1)); let two = iter.next().unwrap(); assert_eq!(two.value(), &sexp!(2)); assert_eq!(iter.next(), None); let three = iter.next().unwrap(); assert_eq!(three.value(), &sexp!(3)); assert_eq!(iter.next(), None);
pub fn vector_iter(&self) -> Option<VectorIter>[src]
Returns an iterator over the elements of a vector.
If the value contained in the datum is not a vector, None is returned.
Trait Implementations
impl Clone for Datum[src]
impl Debug for Datum[src]
impl From<Datum> for Value[src]
impl<'a> From<Ref<'a>> for Datum[src]
fn from(r: Ref<'a>) -> Self[src]
Turns a reference into an owned Datum, by cloning the referenced value and location
information.
impl PartialEq<Datum> for Datum[src]
impl StructuralPartialEq for Datum[src]
Auto Trait Implementations
impl RefUnwindSafe for Datum
impl Send for Datum
impl Sync for Datum
impl Unpin for Datum
impl UnwindSafe for Datum
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,