pub fn add_tag<T: Tag>(&mut self, entity: Entity, tag: T) -> Result<(), EntityMutationError> {
        if !self.is_alive(entity) {
            return Err(EntityMutationError::DoesNotExist);
        }

        if self.get_tag::<T>(entity).is_some() {
            self.remove_tag::<T>(entity)?;
        }

        trace!(
            world = self.id().0,
            ?entity,
            tag = std::any::type_name::<T>(),
            "Adding tag to entity"
        );

        // move the entity into a suitable chunk
        self.move_entity(
            entity,
            &[],
            &[],
            &[(
                TagTypeId::of::<T>(),
                TagMeta::of::<T>(),
                NonNull::new(&tag as *const _ as *mut u8).unwrap(),
            )],
            &[],
        );

        Ok(())
    }
/// Adds a tag to an entity, or sets its value if the tag is
/// already present.
Adds a tag to an entity, or sets its value if the tag is
already present.
Adds a tag to an entity or sets its value if the tag is already present .
pub fn add_tag<T: Tag>(&mut self, entity: Entity, tag: T) -> Result<(), EntityMutationError> {
        if !self.is_alive(entity) {
            return Err(EntityMutationError::DoesNotExist);
        }
        if self.get_tag::<T>(entity).is_some() {
            self.remove_tag::<T>(entity)?;
        }
        trace!(
            world = self.id().0,
            ?entity,
            tag = std::any::type_name::<T>(),
            "Adding tag to entity"
        );
        // move the entity into a suitable chunk
        self.move_entity(
            entity,
            &[],
            &[],
            &[(
                TagTypeId::of::<T>(),
                TagMeta::of::<T>(),
                NonNull::new(&tag as *const _ as *mut u8).unwrap(),
            )],
            &[],
        );
        Ok(())
    }
pub fn add_tag < T : Tag > ( & mut self , entity : Entity , tag : T ) -> Result < ( ) , EntityMutationError > { if ! self . is_alive ( entity ) { return Err ( EntityMutationError :: DoesNotExist ) ; } if self . get_tag :: < T > ( entity ) . is_some ( ) { self . remove_tag :: < T > ( entity ) ? ; } trace ! ( world self id ( ) 0 entity tag std any type_name T ( ) " " ) ; // move the entity into a suitable chunk self . move_entity ( entity , & [ ] , & [ ] , & [ ( TagTypeId :: of :: < T > ( ) , TagMeta :: of :: < T > ( ) , NonNull :: new ( & tag as * const _ as * mut u8 ) . unwrap ( ) , ) ] , & [ ] , ) ; Ok ( ( ) ) }
Adds a tag to an entity, or sets its value if the tag is
already present.
Adds a tag to an entity or sets its value if the tag is already present .
&mut self
entity
Entity
tag
T
&mut self
entity
Entity
tag
T