[−][src]Function edn_rs::to_string
pub fn to_string<T: Serialize>(t: T) -> String
Function for converting Rust types into EDN Strings.
For it to work, the type must implement the Serialize trait.
Use #[derive(Serialize)]
from edn-derive
crate.
Example:
use std::collections::{BTreeMap, BTreeSet}; use edn_derive::Serialize; use edn_rs::{set, map, edn::Edn}; #[derive(Debug, Serialize)] struct ExampleEdn { map: BTreeMap<String, Vec<String>>, set: BTreeSet<i64>, tuples: (i32, bool, char), } fn main() { let edn = ExampleEdn { map: map!{"this is a key".to_string() => vec!["with".to_string(), "many".to_string(), "keys".to_string()]}, set: set!{3i64, 4i64, 5i64}, tuples: (3i32, true, 'd') }; println!("{}", edn_rs::to_string(edn)); // { :map {:this-is-a-key ["with", "many", "keys"]}, :set #{3, 4, 5}, :tuples (3, true, \d), } }