salsa-rs / salsa

A generic framework for on-demand, incrementalized computation. Inspired by adapton, glimmer, and rustc's query system.
https://salsa-rs.netlify.app/
Apache License 2.0
2.12k stars 150 forks source link

Generate builders methods #476

Closed gavrilikhin-d closed 2 months ago

gavrilikhin-d commented 7 months ago

It seems a little inconvenient to pass all fields through XXX::new call. Can salsa generate builder methods for interned, tracked and input structs?

E.g:

#[salsa::input]
pub struct SourceProgram {
    #[return_ref]
    pub text: String,
    #[return_ref]
    pub path: PathBuf,
}

SourceProgram::build().with_text("text").with_path("foo.rs").finish()

P.S: Names for building functions are just for example, you may pick the ones you like

gavrilikhin-d commented 7 months ago

Related to https://github.com/salsa-rs/salsa/issues/385

nikomatsakis commented 6 months ago

Agreed! I would like to generate builders. This seems like a good starter issue, @gavrilikhin-d

nikomatsakis commented 6 months ago

See also https://github.com/salsa-rs/salsa/pull/418 -- I forget exactly what that PR is doing, maybe same general thing?