From 6556de7cd2712038af4ed7c6ffd4239d7219173d Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 12 Feb 2023 15:51:47 +0000 Subject: [PATCH] Allow function argument overloading on custom JavaScript classes --- lib/src/fnc/script/classes/duration.rs | 4 ++-- lib/src/fnc/script/classes/record.rs | 4 ++-- lib/src/fnc/script/classes/uuid.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/fnc/script/classes/duration.rs b/lib/src/fnc/script/classes/duration.rs index bb383a3a..1cee421b 100644 --- a/lib/src/fnc/script/classes/duration.rs +++ b/lib/src/fnc/script/classes/duration.rs @@ -17,7 +17,7 @@ pub mod duration { impl Duration { #[quickjs(constructor)] - pub fn new(value: String) -> Self { + pub fn new(value: String, args: Rest) -> Self { Self { value, } @@ -27,7 +27,7 @@ pub mod duration { &self.value } /// Convert the object to a string - pub fn toString(&self) -> String { + pub fn toString(&self, args: Rest) -> String { self.value.to_owned() } /// Convert the object to JSON diff --git a/lib/src/fnc/script/classes/record.rs b/lib/src/fnc/script/classes/record.rs index 76756011..ac96305e 100644 --- a/lib/src/fnc/script/classes/record.rs +++ b/lib/src/fnc/script/classes/record.rs @@ -19,7 +19,7 @@ pub mod record { impl Record { #[quickjs(constructor)] - pub fn new(tb: String, id: String) -> Self { + pub fn new(tb: String, id: String, args: Rest) -> Self { Self { tb, id, @@ -34,7 +34,7 @@ pub mod record { &self.id } /// Convert the object to a string - pub fn toString(&self) -> String { + pub fn toString(&self, args: Rest) -> String { format!("{}:{}", self.tb, self.id) } /// Convert the object to JSON diff --git a/lib/src/fnc/script/classes/uuid.rs b/lib/src/fnc/script/classes/uuid.rs index 06c75c37..6dd90802 100644 --- a/lib/src/fnc/script/classes/uuid.rs +++ b/lib/src/fnc/script/classes/uuid.rs @@ -17,7 +17,7 @@ pub mod uuid { impl Uuid { #[quickjs(constructor)] - pub fn new(value: String) -> Self { + pub fn new(value: String, args: Rest) -> Self { Self { value, } @@ -27,7 +27,7 @@ pub mod uuid { &self.value } /// Convert the object to a string - pub fn toString(&self) -> String { + pub fn toString(&self, args: Rest) -> String { self.value.to_owned() } /// Convert the object to JSON