![]() ![]() Unless you explicitly state otherwise, any contribution intentionally submittedįor inclusion in this crate by you, as defined in the Apache-2.0 license, shallīe dual licensed as above, without any additional terms or conditions. As &dyn Any (a borrowed trait object), it has the is and downcastref methods, to test if the contained value is of a given type, and to get a reference to the inner value as a type. downcast 0.11.0 Docs. Licensed under either of Apache License, Version API documentation for the Rust Any trait in crate downcast. Use thiserror if youĪre a library that wants to design your own dedicated error type(s) so that onįailures the caller gets exactly the information that you choose. Use Anyhow if you don't care what error type your functions return, you just The necessary improvements for this to be possible as part of RFC 2504. Rather than a separate trait failure ::Fail. EugeneOZ on To be dynamic, 'Any' should be able to represent literally ANY type. As &dyn Any (a borrowed trait object), it has the is// and downcastref methods, to test if the contained value is of a given type,// and to get a reference to the inner value as a type. ![]() That is a safe analogue of casting a void pointer to another type. If the underlying error is not of type T, this will return None. The purpose of the Any trait is to make it possible to pass around values of any type and dynamically downcast them, as the documentation indicates. The anyhow ::Error type works something like failure ::Error, but unlikeįailure ours is built around the standard library's std :: error ::Error trait Attempts to downcast this failure to a concrete type by reference. Type inside a function that returns Anyhow's error type. It offers core types, like Vecand Option, library-defined operations on language primitives, standard macros, I/Oand multithreading, among many other things.Rust any downcast portable#map_err ( Error ::msg ) when working with a non-Anyhow error The Rust Standard Library is the foundation of portable Rust software, a set of minimal and battle-tested shared abstractions for the broader Rust ecosystem. Std :: error ::Error trait which is only available through std, no_std mode will Since the ?-based error conversions would normally rely on the use anyhow ::Result fn get_cluster_info ( ) -> Result Within the function, use ? to easily propagate any error that implements the Arc can then be further downcast into Arc where ConcreteType implements Trait. Use Result, or equivalently anyhow ::Result, as the Convert Arc (where Trait: Downcast) to Arc.This library provides anyhow ::Error, a trait object based error typeįor easy idiomatic error handling in Rust applications. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |