nrc / derive-new

derive simple constructor functions for Rust structs
MIT License
525 stars 35 forks source link

Struct member is private #68

Open aminballoon opened 4 months ago

aminballoon commented 4 months ago

I want to define const struct like Python DataClasses I have 2 files 1st is datatype.rs

use derive_new::new;

#[derive(new)]
struct NameSpaces {

    #[new(value = "\"/dog\".to_string()")]
    dog: String,

    #[new(value = "\"/cat\".to_string()")]
    cat: String,

}

2nd is main.rx

mod datatype;

#[tokio::main]
async fn main() {

    let ns = datatype::NameSpaces::new();
    println!("{}", ns.dog);

    std::future::pending::<()>().await;
}

Issue is field `dog` of `NameSpaces` is private Does it possible to change it to global ??