v2.0.0
Breaking Changes
- The
format
module has been refactored to passWrite
by value rather than
by mutable reference. Most code should not be affected becauseWrite
is
implemented for&mut Write
.
Changed
-
The unit type
()
andOption::None
are more fuzzy when deserializing. If
users deserialize a value that was serialized asNone
or()
, the default
value will be returned rather than an error, when possible. For example:let unit = pot::to_vec(&())?; assert_eq!(pot::from_slice(&unit).unwrap(), 0_u32) let none = pot::to_vec(&Option::<bool>::None)?; assert_eq!(pot::from_slice(&unit).unwrap(), 0_u32)
This is not practically useful for most users, but when designing traits that
have associated serializable types, sometimes it's useful to use()
when no
data needs to be stored. However, it can be painful to update existing data
when switching between()
and other types, as Serde offers no built-in
transmutation. Pot now offers this internally.
Added
Value::from_serialize
andValue::deserialize_as
have been added, allowing
Value
to be transmuted directly from types that implementSerialize
and
Deserialize
.OwnedValue
is a new-type wrapper aroundValue<'static>
that can be used in
situations whereDeserializeOwned
is a requirement. This type is needed
becauseValue<'a>
can borrow from the source of the deserialization, and
this flexibility causes lifetime errors when trying to deserialize a
Value<'static>
asDeserializeOwned
.