[][src]Trait lexpr::value::Index

pub trait Index: Sealed { }

A type that can be used to index into a lexpr::Value.

The get method of Value accept any type that implements Index, as does the square-bracket indexing operator. This trait is implemented for strings and Value, both of which can be used to index into association lists, and for usize which is used to index into to lists by element index.

Note that improper lists are only indexable by usize, not by strings.

This trait is sealed and cannot be implemented for types outside of lexpr.

Examples

let data = sexp!(((foo 42) (bar . (1 2 3))));

// Data is an association list so it can be indexed with a string.
let bar = &data["bar"];

// Bar is a list so it can be indexed with an integer.
let second = &bar[1];

assert_eq!(second, 2);

Implementations on Foreign Types

impl Index for usize[src]

impl Index for str[src]

impl Index for String[src]

impl<'a, T: ?Sized> Index for &'a T where
    T: Index
[src]

Loading content...

Implementors

impl Index for Value[src]

Loading content...