Jst - A new library to write object like JavaScript with Rust

Hey guys

I wrote a small library for writing js object like in rust. Can be nice when you want to write an unstructured object.

I will happy to know what you think :slight_smile:

github
crates.io

Thanks

Example

#[macro_use(obj, val, arr)]
extern crate jst;
use jst::{Obj, Val};

fn main() {
 
    let details = obj! {
        love_go: null,
        love_c: undefined,
        love_rust: true
    };

    let address = obj! {
        x: 5,
        y: 9
    };

    let key = "some key";

    let person = obj! {
        name: "Mosh",
        languages: [ "rust", "go", "typescript"],
        address,
        ...details,
        [key]: "value"
    };

   // Not getting out of range error (instead getting Val::Undef)
    if let Val::Str(s) = &person["languages"][3] {
        println!("Not happened {}", s);
    }

    println!("{}", person);
}
2 Likes