Skip to content

Commit

Permalink
fix: dropping the Value in Value::from
Browse files Browse the repository at this point in the history
  • Loading branch information
hulxv committed Nov 22, 2024
1 parent d0ebb14 commit 83e1404
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions source/ports/rs_port2/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait Create<T> {
}

trait From<T> {
fn from(&self, value: T) -> Self;
fn from(&mut self, value: T) -> &Self;
}

trait To<T> {
Expand All @@ -26,9 +26,9 @@ impl Create<i64> for Value {
}

impl From<i64> 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
}
}

Expand All @@ -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);
Expand Down

0 comments on commit 83e1404

Please sign in to comment.