Skip to main content

downcast_resource

Function downcast_resource 

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

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

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

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

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

§Arguments

  • resource - Reference to resources

§Returns

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

§参数

  • resource - 资源的引用

§返回值

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