Struct Context

Source
pub struct Context {
Show 13 fields pub true_value: PyIntRef, pub false_value: PyIntRef, pub none: PyRef<PyNone>, pub empty_tuple: PyTupleRef, pub empty_frozenset: PyRef<PyFrozenSet>, pub empty_str: &'static PyStrInterned, pub empty_bytes: PyRef<PyBytes>, pub ellipsis: PyRef<PyEllipsis>, pub not_implemented: PyRef<PyNotImplemented>, pub types: TypeZoo, pub exceptions: ExceptionZoo, pub int_cache_pool: Vec<PyIntRef>, pub names: ConstName, /* private fields */
}

Fields§

§true_value: PyIntRef§false_value: PyIntRef§none: PyRef<PyNone>§empty_tuple: PyTupleRef§empty_frozenset: PyRef<PyFrozenSet>§empty_str: &'static PyStrInterned§empty_bytes: PyRef<PyBytes>§ellipsis: PyRef<PyEllipsis>§not_implemented: PyRef<PyNotImplemented>§types: TypeZoo§exceptions: ExceptionZoo§int_cache_pool: Vec<PyIntRef>§names: ConstName

Implementations§

Source§

impl Context

Source

pub const INT_CACHE_POOL_RANGE: RangeInclusive<i32>

Source

pub fn genesis() -> &'static PyRc<Self>

Source

pub fn intern_str<S: InternableString>(&self, s: S) -> &'static PyStrInterned

Source

pub fn interned_str<S: MaybeInternedString + ?Sized>( &self, s: &S, ) -> Option<&'static PyStrInterned>

Source

pub fn none(&self) -> PyObjectRef

Source

pub fn ellipsis(&self) -> PyObjectRef

Source

pub fn not_implemented(&self) -> PyObjectRef

Source

pub fn new_pyref<T, P>(&self, value: T) -> PyRef<P>
where T: Into<P>, P: PyPayload,

Source

pub fn new_int<T: Into<BigInt> + ToPrimitive>(&self, i: T) -> PyIntRef

Source

pub fn new_bigint(&self, i: &BigInt) -> PyIntRef

Source

pub fn new_float(&self, value: f64) -> PyRef<PyFloat>

Source

pub fn new_complex(&self, value: Complex64) -> PyRef<PyComplex>

Source

pub fn new_str(&self, s: impl Into<PyStr>) -> PyRef<PyStr>

Source

pub fn interned_or_new_str<S, M>(&self, s: S) -> PyRef<PyStr>
where S: Into<PyStr> + AsRef<M>, M: MaybeInternedString,

Source

pub fn new_bytes(&self, data: Vec<u8>) -> PyRef<PyBytes>

Source

pub fn new_bool(&self, b: bool) -> PyIntRef

Source

pub fn new_tuple(&self, elements: Vec<PyObjectRef>) -> PyTupleRef

Source

pub fn new_list(&self, elements: Vec<PyObjectRef>) -> PyListRef

Source

pub fn new_dict(&self) -> PyDictRef

Source

pub fn new_class( &self, module: Option<&str>, name: &str, base: PyTypeRef, slots: PyTypeSlots, ) -> PyTypeRef

Source

pub fn new_exception_type( &self, module: &str, name: &str, bases: Option<Vec<PyTypeRef>>, ) -> PyTypeRef

Source

pub fn new_method_def<F, FKind>( &self, name: &'static str, f: F, flags: PyMethodFlags, doc: Option<&'static str>, ) -> PyRef<HeapMethodDef>
where F: IntoPyNativeFn<FKind>,

Source

pub fn new_member( &self, name: &str, member_kind: MemberKind, getter: fn(&VirtualMachine, PyObjectRef) -> PyResult, setter: Option<fn(&VirtualMachine, PyObjectRef, PySetterValue) -> PyResult<()>>, class: &'static Py<PyType>, ) -> PyRef<PyMemberDescriptor>

Source

pub fn new_readonly_getset<F, T>( &self, name: impl Into<String>, class: &'static Py<PyType>, f: F, ) -> PyRef<PyGetSet>
where F: IntoPyGetterFunc<T>,

Source

pub fn new_getset<G, S, T, U>( &self, name: impl Into<String>, class: &'static Py<PyType>, g: G, s: S, ) -> PyRef<PyGetSet>
where G: IntoPyGetterFunc<T>, S: IntoPySetterFunc<U>,

Source

pub fn new_base_object( &self, class: PyTypeRef, dict: Option<PyDictRef>, ) -> PyObjectRef

Source

pub fn new_code(&self, code: impl IntoCodeObject) -> PyRef<PyCode>

Trait Implementations§

Source§

impl<'a> AsBag for &'a Context

Source§

type Bag = PyObjBag<'a>

Source§

fn as_bag(self) -> PyObjBag<'a>

Source§

impl AsRef<Context> for Context

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Context> for VirtualMachine

Source§

fn as_ref(&self) -> &Context

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for Context

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Context

§

impl !RefUnwindSafe for Context

§

impl !Send for Context

§

impl !Sync for Context

§

impl Unpin for Context

§

impl !UnwindSafe for Context

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U

Source§

impl<T> PyThreadingConstraint for T