pub trait ValueConstructor<T> {
// Required method
fn make_value() -> T;
}Expand description
Something that can construct a value of type T.
Used when a field has been removed using the AbiRemoved type.
Usage:
use savefile::{AbiRemoved, ValueConstructor};
use savefile_derive::Savefile;
#[derive(Savefile)]
struct MyStruct {
my_field: String,
#[savefile_versions="..0"]
my_removed_field: AbiRemoved<String, MyStructMyRemovedFieldFactory>,
}
struct MyStructMyRemovedFieldFactory;
impl ValueConstructor<String> for MyStructMyRemovedFieldFactory {
fn make_value() -> String {
"Default value for when values of version 0 are to be serialized".to_string()
}
}Required Methods§
Sourcefn make_value() -> T
fn make_value() -> T
Create a value of type T. This is used by the AbiRemoved trait to be able to invent values when writing removed fields from old protocols.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.