pub struct CastError<'a, 'py> {
from: Borrowed<'a, 'py, PyAny>,
classinfo: Bound<'py, PyAny>,
}Expand description
Error that indicates an object was not an instance of a given target type.
Fields§
§from: Borrowed<'a, 'py, PyAny>The original object that failed the isinstance check.
classinfo: Bound<'py, PyAny>The type we tried (and failed) to convert to.
(see PyTypeCheck::classinfo_object)
Implementations§
Source§impl<'a, 'py> CastError<'a, 'py>
impl<'a, 'py> CastError<'a, 'py>
Sourcepub fn new(from: Borrowed<'a, 'py, PyAny>, classinfo: Bound<'py, PyAny>) -> Self
pub fn new(from: Borrowed<'a, 'py, PyAny>, classinfo: Bound<'py, PyAny>) -> Self
Create a new CastError representing a failure to interpret a smart pointer to
from as a type from the given classinfo.
As with PyTypeCheck::classinfo_object,
valid classinfo values are those which can be used with isinstance, such as type
objects, tuples of type objects, or typing.Union instances.
Trait Implementations§
Source§impl Error for CastError<'_, '_>
impl Error for CastError<'_, '_>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
Source§#[doc(hidden)]fn type_id(&self, _: Internal) -> TypeIdwhere
Self: 'static,
#[doc(hidden)]fn type_id(&self, _: Internal) -> TypeIdwhere
Self: 'static,
🔬This is a nightly-only experimental API. (
error_type_id)Gets the
TypeId of self.1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl<'a, 'py> Freeze for CastError<'a, 'py>
impl<'a, 'py> !RefUnwindSafe for CastError<'a, 'py>
impl<'a, 'py> !Send for CastError<'a, 'py>
impl<'a, 'py> !Sync for CastError<'a, 'py>
impl<'a, 'py> Unpin for CastError<'a, 'py>
impl<'a, 'py> UnsafeUnpin for CastError<'a, 'py>
impl<'a, 'py> !UnwindSafe for CastError<'a, 'py>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
🔬This is a nightly-only experimental API. (
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)The largest safe length for a
[Self]. Read more