py-rs 0.1.1

generate python bindings from rust types
Documentation
#![allow(unused)]

use py_rs::PY;

#[derive(PY)]
#[py(export, export_to = "issue_232/")]
struct State {
    a: Result<EnumWithName, String>,
    b: Result<EnumWithName, String>,
}

#[derive(PY)]
#[py(export, export_to = "issue_232/")]
struct StateInlined {
    #[py(inline)]
    a: Result<EnumWithName, String>,
    #[py(inline)]
    b: Result<EnumWithName, String>,
}

#[derive(PY)]
#[py(export, export_to = "issue_232/")]
struct StateInlinedVec {
    #[py(inline)]
    a: Vec<Result<EnumWithName, String>>,
    #[py(inline)]
    b: Vec<Result<EnumWithName, String>>,
}

#[derive(PY)]
#[py(export, export_to = "issue_232/")]
struct EnumWithName {
    name: String,
    inner: Enum,
}

#[derive(PY)]
#[py(export, export_to = "issue_232/")]
enum Enum {
    A,
    B,
}

#[test]
#[cfg(not(feature = "import-esm"))]
fn issue_232() {
    println!("{}", StateInlinedVec::export_to_string().unwrap());
    assert_eq!(
        StateInlined::export_to_string().unwrap(),
        "// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n\
        import type { Enum } from \"./Enum\";\n\
        \n\
        export type StateInlined = { \
            a: { Ok : { name: string, inner: Enum, } } | { Err : string }, \
            b: { Ok : { name: string, inner: Enum, } } | { Err : string }, \
        };\n"
    );
    assert_eq!(
        State::export_to_string().unwrap(),
        "// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n\
        import type { EnumWithName } from \"./EnumWithName\";\n\
        \n\
        export type State = { \
            a: { Ok : EnumWithName } | { Err : string }, \
            b: { Ok : EnumWithName } | { Err : string }, \
        };\n"
    );
}