Skip to main content

Object

Trait Object 

Source
pub trait Object: Sized {
    // Provided methods
    fn id(&self) -> usize { ... }
    fn type(&self) -> String { ... }
    fn is<T: Object>(&self, other: &Option<T>) -> bool { ... }
    fn __getattribute__(&self, _name: impl AsRef<str>) -> Option<impl Object> { ... }
    fn __dir__(&self) -> Vec<impl AsRef<str>> { ... }
}
Expand description

The Python Object. Anything that implements this trait is a Python Object.

Provided Methods§

Source

fn id(&self) -> usize

Returns the unique identifier of the object, which is the memory address of the object.

Source

fn type(&self) -> String

Returns the type name of the object.

Source

fn is<T: Object>(&self, other: &Option<T>) -> bool

Returns the type name of the object.

Source

fn __getattribute__(&self, _name: impl AsRef<str>) -> Option<impl Object>

getattribute is called to look up an attribute of the object.

Source

fn __dir__(&self) -> Vec<impl AsRef<str>>

dir is called to list the attributes of the object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Object for &str

Source§

impl Object for String

Source§

impl Object for bool

Source§

impl Object for char

Source§

impl Object for f32

Source§

impl Object for f64

Source§

impl Object for i8

Source§

impl Object for i16

Source§

impl Object for i32

Source§

impl Object for i64

Source§

impl Object for i128

Source§

impl Object for u8

Source§

impl Object for u16

Source§

impl Object for u32

Source§

impl Object for u64

Source§

impl Object for u128

Source§

impl<T: Object> Object for Option<T>

Source§

fn is<U: Object>(&self, other: &Option<U>) -> bool

Implementors§