diff --git a/source/ports/rs_port2/src/value.rs b/source/ports/rs_port2/src/value.rs index 9c4883b48..5eceaebd4 100644 --- a/source/ports/rs_port2/src/value.rs +++ b/source/ports/rs_port2/src/value.rs @@ -9,7 +9,7 @@ trait Create { } trait From { - fn from(&self, value: T) -> Self; + fn from(&mut self, value: T) -> &Self; } trait To { @@ -26,9 +26,9 @@ impl Create for Value { } impl From for Value { - fn from(&self, value: i64) -> Self { - let val = unsafe { metacall_value_from_long(self.0, value as c_long) }; - Self(val) + fn from(&mut self, value: i64) -> &Self { + self.0 = unsafe { metacall_value_from_long(self.0, value as c_long) }; + self } } @@ -55,7 +55,7 @@ mod test { #[test] fn metacall_create_value() { // assert!(unsafe { metacall_initialize() } == 0); - let val = Value::new(123); + let mut val = Value::new(123); let result = val.to(); assert!(result == 123); val.from(33);