11use crate :: conversion:: IntoPyObject ;
22use crate :: inspect:: TypeHint ;
3- use crate :: pyclass:: boolean_struct:: { private:: Boolean , False , True } ;
4- use std:: marker:: PhantomData ;
5- use std:: ops:: Deref ;
63
74/// Trait to guess a function Python return type
85///
@@ -20,57 +17,6 @@ impl<T: PyReturnType, E> PyReturnType for Result<T, E> {
2017 const OUTPUT_TYPE : TypeHint = T :: OUTPUT_TYPE ;
2118}
2219
23- /// Hack to guess if the output type is the empty tuple
24- ///
25- /// Inspiration: <https://github.com/GoldsteinE/gh-blog/blob/master/const_deref_specialization/src/lib.md>
26- /// TL;DR: with closure we can get the compiler to return us the output type of the usual deref-based specialization
27- pub const fn is_empty_tuple_from_closure < B : Boolean > (
28- _closure_returning_bool : & impl FnOnce ( ) -> B ,
29- ) -> bool {
30- B :: VALUE
31- }
32-
33- pub struct IsEmptyTupleChecker < T > {
34- _marker : PhantomData < T > ,
35- }
36-
37- impl < T > IsEmptyTupleChecker < T > {
38- #[ allow( clippy:: new_without_default) ]
39- pub const fn new ( ) -> Self {
40- Self {
41- _marker : PhantomData ,
42- }
43- }
44- }
45-
46- impl IsEmptyTupleChecker < ( ) > {
47- pub fn check ( & self ) -> True {
48- True
49- }
50- }
51-
52- impl < E > IsEmptyTupleChecker < Result < ( ) , E > > {
53- pub fn check ( & self ) -> True {
54- True
55- }
56- }
57-
58- impl < T > Deref for IsEmptyTupleChecker < T > {
59- type Target = IsEmptyTupleCheckerFalse ;
60-
61- fn deref ( & self ) -> & IsEmptyTupleCheckerFalse {
62- & IsEmptyTupleCheckerFalse
63- }
64- }
65-
66- pub struct IsEmptyTupleCheckerFalse ;
67-
68- impl IsEmptyTupleCheckerFalse {
69- pub fn check ( & self ) -> False {
70- False
71- }
72- }
73-
7420#[ repr( C ) ]
7521pub struct SerializedIntrospectionFragment < const LEN : usize > {
7622 pub length : u32 ,
0 commit comments