7 releases (4 breaking)

✓ Uses Rust 2018 edition

1.0.0-rc2 Nov 23, 2019
1.0.0-rc1 Nov 9, 2019
0.5.0 Oct 27, 2019
0.4.0 Oct 7, 2019
0.1.0 Sep 29, 2019

#39 in Build Utils

Download history 17/week @ 2019-11-29 7/week @ 2019-12-06 387/week @ 2019-12-13 7/week @ 2019-12-27 6/week @ 2020-01-03 8/week @ 2020-01-10 36/week @ 2020-01-17 1/week @ 2020-01-31 7/week @ 2020-02-07 4/week @ 2020-02-14 22/week @ 2020-02-21 40/week @ 2020-02-28 14/week @ 2020-03-06 8/week @ 2020-03-13

216 downloads per month

Custom license

46KB
1K SLoC

Proffer

CircleCI crates.io License Coverage Status

API Documentation

Code generation for Rust

Namely useful for generating source code from other data such as JSON

Example

See the documentation for more examples

use proffer::*;
let ipl = Impl::new("That")
    .add_generic(Generic::new("T").add_trait_bounds(vec!["ToString"]).to_owned())
    .add_function(
        Function::new("foo")
            .set_is_pub(true)
            .add_parameter(Parameter::new("bar1", "T"))
            .add_parameter(Parameter::new("bar2", "S"))
            .set_return_ty("T")
            .add_generic(Generic::new("S"))
            .set_body("bar")
            .to_owned()
    ).to_owned();

let expected = r#"
    impl<T> That<T>
        where
            T: ToString,
    {
        pub fn foo<S>(bar1: T, bar2: S) -> T
            where
                S: ,
        {
            bar
        }
    }
"#;

let src_code = ipl.generate();
println!("{}", &src_code);

assert_eq!(
    norm_whitespace(expected),
    norm_whitespace(&src_code)
)

Dependencies

~7MB
~169K SLoC