#builder #separate #struct #offers #build #string #colon

macro colonbuilder

A rust builder offers from_str method to build struct from colon separate string

7 releases

0.1.6 Feb 26, 2023
0.1.5 Feb 25, 2023

#1046 in Procedural macros

MIT/Apache

8KB
158 lines

Colon Builder

build status

Build structure from colon separate fields like

name:colon builder
hobbies: book,game,football
TV: once a while

Sample code

#[derive(ColonBuilder)]
struct Person {
    #[cb(require)]
    name: String,
    hobbies: Vec<String>,
    #[cb(abbr="TV")]
    favoriteTVShows: Option<String>
}

let p = Person::from_str("name:lu\nTV:show");

cargo expand --test test_builder to expand the test file test_builder.rs

Dependencies

~3.5–4.5MB
~89K SLoC