Method
into_exact_or
(
self,
ctx: &Context,
f: impl FnOnce(Self) -> PyRefExact<T>,
)
Source from the content-addressed store, hash-verified
| 120 | |
| 121 | impl<T: PyPayload> PyRef<T> { |
| 122 | pub fn into_exact_or( |
| 123 | self, |
| 124 | ctx: &Context, |
| 125 | f: impl FnOnce(Self) -> PyRefExact<T>, |
| 126 | ) -> PyRefExact<T> { |
| 127 | if self.class().is(T::class(ctx)) { |
| 128 | unsafe { PyRefExact::new_unchecked(self) } |
| 129 | } else { |
| 130 | f(self) |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | /// PyRef but guaranteed not to be a subtype instance |
Tested by
no test coverage detected