mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
as_mapping never fails
This commit is contained in:
@@ -1253,12 +1253,12 @@ mod array {
|
||||
}
|
||||
|
||||
impl AsMapping for PyArray {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyMappingMethods> {
|
||||
Ok(PyMappingMethods {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
PyMappingMethods {
|
||||
length: Some(Self::length),
|
||||
subscript: Some(Self::subscript),
|
||||
ass_subscript: Some(Self::ass_subscript),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn length(zelf: PyObjectRef, vm: &VirtualMachine) -> PyResult<usize> {
|
||||
|
||||
@@ -756,12 +756,12 @@ impl<'a> BufferResizeGuard<'a> for PyByteArray {
|
||||
}
|
||||
|
||||
impl AsMapping for PyByteArray {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyMappingMethods> {
|
||||
Ok(PyMappingMethods {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
PyMappingMethods {
|
||||
length: Some(Self::length),
|
||||
subscript: Some(Self::subscript),
|
||||
ass_subscript: Some(Self::ass_subscript),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -569,12 +569,12 @@ impl BufferInternal for PyRef<PyBytes> {
|
||||
}
|
||||
|
||||
impl AsMapping for PyBytes {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyMappingMethods> {
|
||||
Ok(PyMappingMethods {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
PyMappingMethods {
|
||||
length: Some(Self::length),
|
||||
subscript: Some(Self::subscript),
|
||||
ass_subscript: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -416,12 +416,12 @@ impl PyDict {
|
||||
}
|
||||
|
||||
impl AsMapping for PyDict {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyMappingMethods> {
|
||||
Ok(PyMappingMethods {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
PyMappingMethods {
|
||||
length: Some(Self::length),
|
||||
subscript: Some(Self::subscript),
|
||||
ass_subscript: Some(Self::ass_subscript),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -418,12 +418,12 @@ impl PyList {
|
||||
}
|
||||
|
||||
impl AsMapping for PyList {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyMappingMethods> {
|
||||
Ok(PyMappingMethods {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
PyMappingMethods {
|
||||
length: Some(Self::length),
|
||||
subscript: Some(Self::subscript),
|
||||
ass_subscript: Some(Self::ass_subscript),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -151,12 +151,12 @@ impl PyMappingProxy {
|
||||
}
|
||||
|
||||
impl AsMapping for PyMappingProxy {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyMappingMethods> {
|
||||
Ok(PyMappingMethods {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
PyMappingMethods {
|
||||
length: None,
|
||||
subscript: Some(Self::subscript),
|
||||
ass_subscript: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -737,12 +737,12 @@ impl BufferInternal for PyRef<PyMemoryView> {
|
||||
}
|
||||
|
||||
impl AsMapping for PyMemoryView {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyMappingMethods> {
|
||||
Ok(PyMappingMethods {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
PyMappingMethods {
|
||||
length: Some(Self::length),
|
||||
subscript: Some(Self::subscript),
|
||||
ass_subscript: Some(Self::ass_subscript),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -377,12 +377,12 @@ impl PyRange {
|
||||
}
|
||||
|
||||
impl AsMapping for PyRange {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyMappingMethods> {
|
||||
Ok(PyMappingMethods {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
PyMappingMethods {
|
||||
length: Some(Self::length),
|
||||
subscript: Some(Self::subscript),
|
||||
ass_subscript: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -306,12 +306,12 @@ impl PyTuple {
|
||||
}
|
||||
|
||||
impl AsMapping for PyTuple {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyMappingMethods> {
|
||||
Ok(PyMappingMethods {
|
||||
fn as_mapping(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
PyMappingMethods {
|
||||
length: Some(Self::length),
|
||||
subscript: Some(Self::subscript),
|
||||
ass_subscript: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -767,7 +767,7 @@ pub trait AsMapping: PyValue {
|
||||
let zelf = zelf
|
||||
.downcast_ref()
|
||||
.ok_or_else(|| vm.new_type_error("unexpected payload for as_mapping".to_owned()))?;
|
||||
Self::as_mapping(zelf, vm)
|
||||
Ok(Self::as_mapping(zelf, vm))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -792,7 +792,7 @@ pub trait AsMapping: PyValue {
|
||||
})
|
||||
}
|
||||
|
||||
fn as_mapping(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyMappingMethods>;
|
||||
fn as_mapping(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyMappingMethods;
|
||||
|
||||
fn length(zelf: PyObjectRef, _vm: &VirtualMachine) -> PyResult<usize>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user