mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-08-09 21:38:20 +00:00
rename all_entity_fields
to all_field_names
This commit is contained in:
parent
783981dc16
commit
f0156cca36
4 changed files with 11 additions and 17 deletions
|
@ -219,16 +219,14 @@ impl EntityLike {
|
|||
///
|
||||
/// If this is an enum, empty iterator.
|
||||
fn id_fields(&self) -> impl Iterator<Item = &EntityField> {
|
||||
self.all_entity_fields()
|
||||
.filter(|ef| ef.is_entity_id_field())
|
||||
self.all_fields().filter(|ef| ef.is_entity_id_field())
|
||||
}
|
||||
|
||||
/// List of value fields (fields that are not part of the entity's identity across revisions).
|
||||
///
|
||||
/// If this is an enum, empty iterator.
|
||||
fn value_fields(&self) -> impl Iterator<Item = &EntityField> {
|
||||
self.all_entity_fields()
|
||||
.filter(|ef| !ef.is_entity_id_field())
|
||||
self.all_fields().filter(|ef| !ef.is_entity_id_field())
|
||||
}
|
||||
|
||||
/// For the entity, we create a tuple that contains the function ingredients
|
||||
|
|
|
@ -96,7 +96,7 @@ impl EntityLike {
|
|||
/// Iterator over all named fields.
|
||||
///
|
||||
/// If this is an enum, empty iterator.
|
||||
pub(crate) fn all_entity_fields(&self) -> impl Iterator<Item = &EntityField> {
|
||||
pub(crate) fn all_fields(&self) -> impl Iterator<Item = &EntityField> {
|
||||
self.fields.iter().flat_map(|v| v.iter())
|
||||
}
|
||||
|
||||
|
@ -104,14 +104,14 @@ impl EntityLike {
|
|||
///
|
||||
/// If this is an enum, empty vec.
|
||||
pub(crate) fn all_field_names(&self) -> Vec<&syn::Ident> {
|
||||
self.all_entity_fields().map(|ef| ef.name()).collect()
|
||||
self.all_fields().map(|ef| ef.name()).collect()
|
||||
}
|
||||
|
||||
/// Types of all fields (id and value).
|
||||
///
|
||||
/// If this is an enum, empty vec.
|
||||
pub(crate) fn all_field_tys(&self) -> Vec<&syn::Type> {
|
||||
self.all_entity_fields().map(|ef| ef.ty()).collect()
|
||||
self.all_fields().map(|ef| ef.ty()).collect()
|
||||
}
|
||||
|
||||
/// The name of the "identity" struct (this is the name the user gave, e.g., `Foo`).
|
||||
|
@ -280,7 +280,7 @@ impl EntityLike {
|
|||
///
|
||||
/// * `kind`, the attribute name (e.g., `input` or `interned`)
|
||||
pub(crate) fn disallow_id_fields(&self, kind: &str) -> syn::Result<()> {
|
||||
for ef in self.all_entity_fields() {
|
||||
for ef in self.all_fields() {
|
||||
if ef.has_id_attr {
|
||||
return Err(syn::Error::new(
|
||||
ef.name().span(),
|
||||
|
|
|
@ -21,8 +21,7 @@ impl EntityLike {
|
|||
fn generate_input(&self) -> syn::Result<TokenStream> {
|
||||
self.validate_input()?;
|
||||
|
||||
let (config_structs, config_impls) =
|
||||
self.field_config_structs_and_impls(self.all_entity_fields());
|
||||
let (config_structs, config_impls) = self.field_config_structs_and_impls(self.all_fields());
|
||||
|
||||
let id_struct = self.id_struct();
|
||||
let inherent_impl = self.input_inherent_impl();
|
||||
|
@ -56,10 +55,7 @@ impl EntityLike {
|
|||
let field_indices = self.all_field_indices();
|
||||
let field_names: Vec<_> = self.all_field_names();
|
||||
let field_tys: Vec<_> = self.all_field_tys();
|
||||
let field_clones: Vec<_> = self
|
||||
.all_entity_fields()
|
||||
.map(EntityField::is_clone_field)
|
||||
.collect();
|
||||
let field_clones: Vec<_> = self.all_fields().map(EntityField::is_clone_field).collect();
|
||||
let field_getters: Vec<syn::ImplItemMethod> = field_indices.iter().zip(&field_names).zip(&field_tys).zip(&field_clones).map(|(((field_index, field_name), field_ty), is_clone_field)|
|
||||
if !*is_clone_field {
|
||||
parse_quote! {
|
||||
|
@ -180,14 +176,14 @@ impl EntityLike {
|
|||
/// for each "other" field and the entity ingredient. This is the index of
|
||||
/// the entity ingredient within that tuple.
|
||||
fn input_index(&self) -> Literal {
|
||||
Literal::usize_unsuffixed(self.all_entity_fields().count())
|
||||
Literal::usize_unsuffixed(self.all_fields().count())
|
||||
}
|
||||
|
||||
/// For the entity, we create a tuple that contains the function ingredients
|
||||
/// for each field and an entity ingredient. These are the indices
|
||||
/// of the function ingredients within that tuple.
|
||||
fn all_field_indices(&self) -> Vec<Literal> {
|
||||
self.all_entity_fields()
|
||||
self.all_fields()
|
||||
.zip(0..)
|
||||
.map(|(_, i)| Literal::usize_unsuffixed(i))
|
||||
.collect()
|
||||
|
|
|
@ -97,7 +97,7 @@ impl EntityLike {
|
|||
let db_dyn_ty = self.db_dyn_ty();
|
||||
|
||||
let field_getters: Vec<syn::ImplItemMethod> = self
|
||||
.all_entity_fields()
|
||||
.all_fields()
|
||||
.map(|field| {
|
||||
let field_name = field.name();
|
||||
let field_ty = field.ty();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue