Skip to main content

downcast_resource_mut

Function downcast_resource_mut 

Source
pub fn downcast_resource_mut<T: RustConstructorResource + 'static>(
    resource: &mut dyn RustConstructorResource,
) -> Result<&mut T, RustConstructorError>
Expand description

Safely convert mutable references to resources to mutable references to resources of specific types.

安全地将资源可变引用转换为具体类型资源的可变引用。

When using the traversal method to retrieve resources, it should be combined with this method to obtain the mutable reference of the specific type of resource.

当采用遍历的方式取出资源时,应和此方法配合来获取具体类型的资源可变引用。

§Arguments

  • resource - Mutable reference to resources

§Returns

Return a mutable reference to the specific type of resource on success; otherwise, return Err(RustConstructorError).

§参数

  • resource - 资源的可变引用

§返回值

成功时返回具体类型资源的可变引用,否则返回Err(RustConstructorError)