Remove EntityRef::wrap().

This has been superceded by PackedOption.
This commit is contained in:
Jakob Stoklund Olesen
2017-01-19 21:01:54 -08:00
parent 1221d94272
commit 8f2ca7c471

View File

@@ -24,24 +24,6 @@ pub trait EntityRef: Copy + Eq {
/// Get the index that was used to create this entity reference. /// Get the index that was used to create this entity reference.
fn index(self) -> usize; fn index(self) -> usize;
/// Convert an `EntityRef` to an `Optional<EntityRef>` by using the default value as the null
/// reference.
///
/// Entity references are often used in compact data structures like linked lists where a
/// sentinel 'null' value is needed. Normally we would use an `Optional` for that, but
/// currently that uses twice the memory of a plain `EntityRef`.
///
/// This method is called `wrap()` because it is the inverse of `unwrap()`.
fn wrap(self) -> Option<Self>
where Self: Default
{
if self == Self::default() {
None
} else {
Some(self)
}
}
} }
/// A mapping `K -> V` for densely indexed entity references. /// A mapping `K -> V` for densely indexed entity references.