mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Allow empty return type for property setter
This commit is contained in:
@@ -84,9 +84,8 @@ impl PyBaseException {
|
||||
}
|
||||
|
||||
#[pyproperty(name = "__traceback__", setter)]
|
||||
fn set_traceback(&self, traceback: Option<PyTracebackRef>, vm: &VirtualMachine) -> PyResult {
|
||||
fn set_traceback(&self, traceback: Option<PyTracebackRef>, _vm: &VirtualMachine) {
|
||||
self.traceback.replace(traceback);
|
||||
Ok(vm.get_none())
|
||||
}
|
||||
|
||||
#[pyproperty(name = "__cause__")]
|
||||
|
||||
@@ -252,6 +252,11 @@ pub struct PropertyBuilder<'a> {
|
||||
setter: Option<PyObjectRef>,
|
||||
}
|
||||
|
||||
pub trait PropertySetterResult {}
|
||||
|
||||
impl PropertySetterResult for PyResult {}
|
||||
impl PropertySetterResult for () {}
|
||||
|
||||
impl<'a> PropertyBuilder<'a> {
|
||||
pub fn new(ctx: &'a PyContext) -> Self {
|
||||
Self {
|
||||
@@ -270,7 +275,10 @@ impl<'a> PropertyBuilder<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_setter<I, V, F: IntoPyNativeFunc<(I, V), PyResult>>(self, func: F) -> Self {
|
||||
pub fn add_setter<I, V, R: PropertySetterResult, F: IntoPyNativeFunc<(I, V), R>>(
|
||||
self,
|
||||
func: F,
|
||||
) -> Self {
|
||||
let func = self.ctx.new_rustfunc(func);
|
||||
Self {
|
||||
ctx: self.ctx,
|
||||
|
||||
Reference in New Issue
Block a user