From ac837e2cdca6445fb1db3ec684103bc081aa74aa Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 7 Aug 2022 23:52:43 -0400 Subject: [PATCH] rename `set` method to `specify` That's the method name we use when exposing this to users. --- components/salsa-2022-macros/src/tracked_fn.rs | 2 +- components/salsa-2022-macros/src/tracked_struct.rs | 2 +- components/salsa-2022/src/function.rs | 4 ++-- components/salsa-2022/src/function/{set.rs => specify.rs} | 5 ++++- 4 files changed, 8 insertions(+), 5 deletions(-) rename components/salsa-2022/src/function/{set.rs => specify.rs} (89%) diff --git a/components/salsa-2022-macros/src/tracked_fn.rs b/components/salsa-2022-macros/src/tracked_fn.rs index bcb9172f..ee101837 100644 --- a/components/salsa-2022-macros/src/tracked_fn.rs +++ b/components/salsa-2022-macros/src/tracked_fn.rs @@ -416,7 +416,7 @@ fn specify_fn( let (__jar, __runtime) = <_ as salsa::storage::HasJar<#jar_ty>>::jar(#db_var); let __ingredients = <_ as salsa::storage::HasIngredientsFor<#config_ty>>::ingredient(__jar); - __ingredients.function.set(#db_var, #(#arg_names,)* #value_arg) + __ingredients.function.specify(#db_var, #(#arg_names,)* #value_arg) } }, })) diff --git a/components/salsa-2022-macros/src/tracked_struct.rs b/components/salsa-2022-macros/src/tracked_struct.rs index 7c70fa52..53cbfe4a 100644 --- a/components/salsa-2022-macros/src/tracked_struct.rs +++ b/components/salsa-2022-macros/src/tracked_struct.rs @@ -119,7 +119,7 @@ impl SalsaStruct { let __ingredients = <#jar_ty as salsa::storage::HasIngredientsFor< #ident >>::ingredient(__jar); let __id = __ingredients.#struct_index.new_struct(__runtime, (#(#id_field_names,)*)); #( - __ingredients.#value_field_indices.set(__db, __id, #value_field_names); + __ingredients.#value_field_indices.specify(__db, __id, #value_field_names); )* __id } diff --git a/components/salsa-2022/src/function.rs b/components/salsa-2022/src/function.rs index 47aece9b..e533bdd2 100644 --- a/components/salsa-2022/src/function.rs +++ b/components/salsa-2022/src/function.rs @@ -22,7 +22,7 @@ mod inputs; mod lru; mod maybe_changed_after; mod memo; -mod set; +mod specify; mod store; mod sync; @@ -33,7 +33,7 @@ mod sync; /// /// * the `fetch` method, which is invoked when the function is called by the user's code; /// it will return a memoized value if one exists, or execute the function otherwise. -/// * the `set` method, which can only be used when the key is an entity created by the active query. +/// * the `specify` method, which can only be used when the key is an entity created by the active query. /// It sets the value of the function imperatively, so that when later fetches occur, they'll return this value. /// * the `store` method, which can only be invoked with an `&mut` reference, and is to set input fields. pub struct FunctionIngredient { diff --git a/components/salsa-2022/src/function/set.rs b/components/salsa-2022/src/function/specify.rs similarity index 89% rename from components/salsa-2022/src/function/set.rs rename to components/salsa-2022/src/function/specify.rs index 23965230..49065fb6 100644 --- a/components/salsa-2022/src/function/set.rs +++ b/components/salsa-2022/src/function/specify.rs @@ -12,7 +12,10 @@ impl FunctionIngredient where C: Configuration, { - pub fn set<'db>(&self, db: &'db DynDb<'db, C>, key: C::Key, value: C::Value) + /// Specifies the value of the function for the given key. + /// This is a way to imperatively set the value of a function. + /// It only works if the key is a tracked struct created in the current query. + pub fn specify<'db>(&self, db: &'db DynDb<'db, C>, key: C::Key, value: C::Value) where C::Key: TrackedStructInDb>, {