Use PackedOption<Ebb> in the Layout implementation.

The doubly linked lists are terminated with None.

Remove NO_EBB and the Default impl for Ebb.
This commit is contained in:
Jakob Stoklund Olesen
2017-01-19 13:59:57 -08:00
parent 2f6a33f16d
commit b8200d7be9
3 changed files with 49 additions and 47 deletions

View File

@@ -34,6 +34,18 @@ impl<T: ReservedValue> PackedOption<T> {
pub fn expand(self) -> Option<T> {
if self.is_none() { None } else { Some(self.0) }
}
/// Maps a `PackedOption<T>` to `Option<U>` by applying a function to a contained value.
pub fn map<U, F>(self, f: F) -> Option<U>
where F: FnOnce(T) -> U
{
self.expand().map(f)
}
/// Unwrap a packed `Some` value or panic.
pub fn unwrap(self) -> T {
self.expand().unwrap()
}
}
impl<T: ReservedValue> Default for PackedOption<T> {