mecs 0.1.1

An ecs library with a focus on iteration performance
Documentation
//! Entity Ids

// Types
//--------------------------------------------------------------------------------------------------
	/// An entity's ID
	#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)]
	#[cfg_attr(feature = "serde-serialize", derive(serde::Serialize, serde::Deserialize))]
	pub struct EntityId( usize );
//--------------------------------------------------------------------------------------------------

// Impl
//--------------------------------------------------------------------------------------------------
	impl EntityId
	{
		// Constructors
		//--------------------------------------------------------------------------------------------------
			/// Constructs an entity id from a [`usize`]
			#[must_use]
			pub(crate) const fn new(value: usize) -> Self {
				Self(value)
			}
			
			/// Returns a null entity id
			#[must_use]
			pub const fn null() -> Self {
				Self::new(0)
			}
		//--------------------------------------------------------------------------------------------------
		
		// Modifiers
		//--------------------------------------------------------------------------------------------------
			/// Increments this id
			#[allow(clippy::integer_arithmetic)] // We need to add one to get the next id
			pub(crate) fn inc(&mut self) {
				self.0 += 1;
			}
		//--------------------------------------------------------------------------------------------------
		
		// Checks
		//--------------------------------------------------------------------------------------------------
			/// Checks if this id is null
			#[must_use]
			pub const fn is_null(self) -> bool {
				self.0 == 0
			}
		//--------------------------------------------------------------------------------------------------
	}
//--------------------------------------------------------------------------------------------------