Struct cpython::PyFloat [−][src]
pub struct PyFloat(_);
Represents a Python float object.
You can usually avoid directly working with this type
by using ToPyObject
and extract
with f32/f64.
Methods
impl PyFloat[src]
impl PyFloatpub fn new(py: Python, val: c_double) -> PyFloat[src]
pub fn new(py: Python, val: c_double) -> PyFloatCreates a new Python float object.
pub fn value(&self, _py: Python) -> c_double[src]
pub fn value(&self, _py: Python) -> c_doubleGets the value of this float.
Trait Implementations
impl ToPyObject for PyFloat[src]
impl ToPyObject for PyFloatIdentity conversion: allows using existing PyObject instances where
T: ToPyObject is expected.
type ObjectType = PyFloat
fn to_py_object(&self, py: Python) -> PyFloat[src]
fn to_py_object(&self, py: Python) -> PyFloatConverts self into a Python object.
fn into_py_object(self, _py: Python) -> PyFloat[src]
fn into_py_object(self, _py: Python) -> PyFloatConverts self into a Python object. Read more
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R, [src]
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R, Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more
impl<'source> FromPyObject<'source> for PyFloat[src]
impl<'source> FromPyObject<'source> for PyFloatfn extract(py: Python, obj: &'source PyObject) -> PyResult<PyFloat>[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<PyFloat>Extracts Self from the source PyObject.
impl<'source> FromPyObject<'source> for &'source PyFloat[src]
impl<'source> FromPyObject<'source> for &'source PyFloatfn extract(py: Python, obj: &'source PyObject) -> PyResult<&'source PyFloat>[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<&'source PyFloat>Extracts Self from the source PyObject.
impl PythonObject for PyFloat[src]
impl PythonObject for PyFloatfn as_object(&self) -> &PyObject[src]
fn as_object(&self) -> &PyObjectCasts the Python object to PyObject.
fn into_object(self) -> PyObject[src]
fn into_object(self) -> PyObjectCasts the Python object to PyObject.
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self[src]
unsafe fn unchecked_downcast_from(obj: PyObject) -> SelfUnchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
ⓘImportant traits for &'a mut Runsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self[src]
unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a SelfUnchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
impl PythonObjectWithCheckedDowncast for PyFloat[src]
impl PythonObjectWithCheckedDowncast for PyFloatfn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyFloat, PythonObjectDowncastError<'p>>[src]
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyFloat, PythonObjectDowncastError<'p>>Cast from PyObject to a concrete Python object type.
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyFloat, PythonObjectDowncastError<'p>>[src]
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyFloat, PythonObjectDowncastError<'p>>Cast from PyObject to a concrete Python object type.
impl PythonObjectWithTypeObject for PyFloat[src]
impl PythonObjectWithTypeObject for PyFloatfn type_object(py: Python) -> PyType[src]
fn type_object(py: Python) -> PyTypeRetrieves the type object for this Python object type.