Skip to content

Commit 97c2d18

Browse files
committed
AsMapping::AS_MAPPING
1 parent d05645e commit 97c2d18

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

Cargo.lock

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vm/src/function/protocol.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{
44
convert::ToPyObject,
55
identifier,
66
protocol::{PyIter, PyIterIter, PyMapping, PyMappingMethods},
7+
types::AsMapping,
78
AsObject, PyObject, PyObjectRef, PyPayload, PyResult, TryFromObject, VirtualMachine,
89
};
910
use std::{borrow::Borrow, marker::PhantomData};
@@ -110,7 +111,7 @@ impl ArgMapping {
110111
pub fn from_dict_exact(dict: PyDictRef) -> Self {
111112
Self {
112113
obj: dict.into(),
113-
mapping_methods: PyDict::MAPPING_METHODS,
114+
mapping_methods: PyDict::AS_MAPPING,
114115
}
115116
}
116117

vm/src/types/slot.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -896,15 +896,14 @@ pub trait AsBuffer: PyPayload {
896896

897897
#[pyimpl]
898898
pub trait AsMapping: PyPayload {
899+
const AS_MAPPING: PyMappingMethods;
900+
899901
#[inline]
900902
#[pyslot]
901-
fn slot_as_mapping(zelf: &PyObject, vm: &VirtualMachine) -> PyMappingMethods {
902-
let zelf = unsafe { zelf.downcast_unchecked_ref::<Self>() };
903-
Self::as_mapping(zelf, vm)
903+
fn as_mapping(_zelf: &PyObject, _vm: &VirtualMachine) -> PyMappingMethods {
904+
Self::AS_MAPPING
904905
}
905906

906-
fn as_mapping(zelf: &Py<Self>, vm: &VirtualMachine) -> PyMappingMethods;
907-
908907
fn mapping_downcast<'a>(mapping: &'a PyMapping) -> &'a Py<Self> {
909908
unsafe { mapping.obj.downcast_unchecked_ref() }
910909
}

0 commit comments

Comments
 (0)