pyo3/impl_/introspection.rs
1use crate::conversion::IntoPyObject;
2
3/// Trait to guess a function Python return type
4///
5/// It is useful to properly get the return type `T` when the Rust implementation returns e.g. `PyResult<T>`
6pub trait PyReturnType {
7 /// The function return type
8 const OUTPUT_TYPE: &'static str;
9}
10
11impl<'a, T: IntoPyObject<'a>> PyReturnType for T {
12 const OUTPUT_TYPE: &'static str = T::OUTPUT_TYPE;
13}
14
15impl<T: PyReturnType, E> PyReturnType for Result<T, E> {
16 const OUTPUT_TYPE: &'static str = T::OUTPUT_TYPE;
17}