mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-15 01:39:25 +00:00
8dfc578edc
360: Permit renaming constructors, getters and setters r=nikomatsakis a=MihailMihov The goal is to add an option `constructor_name` to `#[salsa::input]`, `#[salsa::interned]` and `#[salsa::tracked]` that allows changing the name of the generated constructor. After that add attributes `get` and `set` to the fields which allow overriding the names of the getters and setters. In the end the following snippet should compile and work: ```rust #[salsa::interned(constructor = from_string)] struct MyInterned { #[get(text)] #[set(set_text)] #[return_ref] field: String, } impl MyInterned { pub fn new(db: &dyn Db, s: impl Display) -> MyInterned { MyInterned::from_string(db, s.to_string()) } pub fn field(self, db: &dyn Db) -> &str { self.text(db) } pub fn set_field(self, db: &mut dyn Db, id: String) { self.set_text(&mut db, id) } } ``` resolves #332 Co-authored-by: Mihail Mihov <mmihov.personal@gmail.com> |
||
---|---|---|
.. | ||
salsa-2022 | ||
salsa-2022-macros | ||
salsa-macros |