pub struct InitStorage<T> { /* private fields */ }Expand description
Implementations§
Source§impl<T> InitStorage<T>
impl<T> InitStorage<T>
Sourcepub const fn uninit() -> Self
pub const fn uninit() -> Self
创建尚未初始化的拥有型存储。
Create owned storage that does not yet contain a T.
Sourcepub fn initialize<I, E>(self, initializer: I) -> Result<InitValue<T>, E>where
I: Init<T, E>,
pub fn initialize<I, E>(self, initializer: I) -> Result<InitValue<T>, E>where
I: Init<T, E>,
消耗未初始化存储,并尝试返回拥有初始化值的对象。 Consume the uninitialized storage and try to return an object that owns the initialized value.
错误不会产生 InitValue;若初始化器失败,调用方只会收到其错误值。
No InitValue is produced on error; if the initializer fails, the caller receives its error value.
该错误路径依赖 Init 的 unsafe 契约:返回错误或 panic 时,存储必须保持未初始化。
The error path relies on Init’s unsafe contract that storage remains uninitialized on error or panic.
Sourcepub fn initialize_default(self) -> InitValue<T>where
T: InitDefault<T, InitMode>,
pub fn initialize_default(self) -> InitValue<T>where
T: InitDefault<T, InitMode>,
在存储槽位中构造默认值并返回拥有该值的对象。 Construct the default value in the storage slot and return an object that owns it.
Sourcepub fn initialize_default_with<I>(self) -> InitValue<T>where
I: InitDefault<T, InitMode>,
pub fn initialize_default_with<I>(self) -> InitValue<T>where
I: InitDefault<T, InitMode>,
使用指定的默认值提供者在存储槽位中构造目标。 Construct the target in the storage slot using the specified default-value provider.
I 可以与 T 不同,只要它实现了针对 T 和普通地址模式的 InitDefault。
I may differ from T as long as it implements InitDefault for T in movable mode.