Enum clojure_reader::edn::Edn
source · #[non_exhaustive]pub enum Edn<'e> {
}
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Vector(Vec<Edn<'e>>)
Set(BTreeSet<Edn<'e>>)
Map(BTreeMap<Edn<'e>, Edn<'e>>)
List(Vec<Edn<'e>>)
Key(&'e str)
Symbol(&'e str)
Str(&'e str)
Int(i64)
Double(OrderedFloat<f64>)
Rational((i64, i64))
Char(char)
Bool(bool)
Nil
Implementations§
source§impl<'e> Edn<'e>
impl<'e> Edn<'e>
sourcepub fn get(&self, e: &Self) -> Option<&Self>
pub fn get(&self, e: &Self) -> Option<&Self>
Examples found in repository?
examples/get-nth.rs (line 13)
5 6 7 8 9 10 11 12 13 14 15 16 17
fn maybe_forty_two<'a>(edn: &'a Edn<'a>) -> Option<&Edn<'a>> {
// This roughly tries to match clojure's get and nth
// (-> (clojure.edn/read-string "{:foo {猫 {{:foo :bar} [1 2 42 3]}}}")
// (get :foo)
// (get (symbol "猫"))
// (get {:foo :bar})
// (nth 2))
edn
.get(&Edn::Key(":foo"))?
.get(&Edn::Symbol("猫"))?
.get(&Edn::Map(BTreeMap::from([(Edn::Key(":foo"), Edn::Key(":bar"))])))?
.nth(2)
}
sourcepub fn nth(&self, i: usize) -> Option<&Self>
pub fn nth(&self, i: usize) -> Option<&Self>
Examples found in repository?
examples/get-nth.rs (line 16)
5 6 7 8 9 10 11 12 13 14 15 16 17
fn maybe_forty_two<'a>(edn: &'a Edn<'a>) -> Option<&Edn<'a>> {
// This roughly tries to match clojure's get and nth
// (-> (clojure.edn/read-string "{:foo {猫 {{:foo :bar} [1 2 42 3]}}}")
// (get :foo)
// (get (symbol "猫"))
// (get {:foo :bar})
// (nth 2))
edn
.get(&Edn::Key(":foo"))?
.get(&Edn::Symbol("猫"))?
.get(&Edn::Map(BTreeMap::from([(Edn::Key(":foo"), Edn::Key(":bar"))])))?
.nth(2)
}
Trait Implementations§
source§impl<'e> Ord for Edn<'e>
impl<'e> Ord for Edn<'e>
source§impl<'e> PartialEq for Edn<'e>
impl<'e> PartialEq for Edn<'e>
source§impl<'e> PartialOrd for Edn<'e>
impl<'e> PartialOrd for Edn<'e>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<'e> Eq for Edn<'e>
impl<'e> StructuralPartialEq for Edn<'e>
Auto Trait Implementations§
impl<'e> Freeze for Edn<'e>
impl<'e> RefUnwindSafe for Edn<'e>
impl<'e> Send for Edn<'e>
impl<'e> Sync for Edn<'e>
impl<'e> Unpin for Edn<'e>
impl<'e> UnwindSafe for Edn<'e>
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