Use PackedOption<Value> instead of NO_VALUE.
- Remove NO_VALUE and ExpandedValue::None. - Remove the Default implelmentation for Value. - InstructionData::second_result() returns an Option<Value>. - InstructionData::second_result() returns a reference to the packed option.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
//! to represent `None`.
|
||||
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
|
||||
/// Types that have a reserved value which can't be created any other way.
|
||||
pub trait ReservedValue: Eq {
|
||||
@@ -46,6 +47,11 @@ impl<T: ReservedValue> PackedOption<T> {
|
||||
pub fn unwrap(self) -> T {
|
||||
self.expand().unwrap()
|
||||
}
|
||||
|
||||
/// Takes the value out of the packed option, leaving a `None` in its place.
|
||||
pub fn take(&mut self) -> Option<T> {
|
||||
mem::replace(self, None.into()).expand()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ReservedValue> Default for PackedOption<T> {
|
||||
|
||||
Reference in New Issue
Block a user