clojure_reader::edn

Function read_string

Source
pub fn read_string(edn: &str) -> Result<Edn<'_>, Error>
Expand description

Reads one object from the &str.

§Errors

See crate::error::Error.

Examples found in repository?
examples/get-nth.rs (line 20)
19
20
21
22
23
fn main() {
  let e = edn::read_string("{:foo {猫 {{:foo :bar} [1 2 42 3]}}}").unwrap();
  let edn = maybe_forty_two(&e).unwrap();
  assert_eq!(edn, &Edn::Int(42));
}
More examples
Hide additional examples
examples/read_quotes.rs (line 33)
29
30
31
32
33
34
35
36
37
38
39
40
fn quotify(s: &str) -> Edn<'_> {
  let (edn, rest) = edn::read(s).unwrap();

  let edn = if edn == Edn::Symbol("'") {
    Edn::List(vec![Edn::Symbol("quote"), edn::read_string(rest).unwrap()])
  } else {
    edn
  };

  let edn = wrap_quote(edn);
  edn
}