From d70f5ef2903cae9156318a27a07423b0add1247e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 28 Jan 2022 16:07:19 +0100 Subject: [PATCH 1/4] Refactor --- src/model.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/model.rs b/src/model.rs index 87e64c616..15aa5ab2c 100644 --- a/src/model.rs +++ b/src/model.rs @@ -25,15 +25,16 @@ impl Model { pub fn lib_path(&self) -> String { let path = format!("{}/target/debug/", self.path(),); - let file: String; - if cfg!(windows) { - file = format!("{}.dll", self.name()) + + let file = if cfg!(windows) { + format!("{}.dll", self.name()) } else if cfg!(target_os = "macos") { - file = format!("lib{}.dylib", self.name()) + format!("lib{}.dylib", self.name()) } else { //Unix - file = format!("lib{}.so", self.name()) - } + format!("lib{}.so", self.name()) + }; + format!("{}{}", path, file) } From f5020b6c8249cc501ab34e5f46b66520c8a1fd1c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 28 Jan 2022 16:08:42 +0100 Subject: [PATCH 2/4] Merge two `format!` calls --- src/model.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/model.rs b/src/model.rs index 15aa5ab2c..d5d148f6d 100644 --- a/src/model.rs +++ b/src/model.rs @@ -24,8 +24,6 @@ impl Model { } pub fn lib_path(&self) -> String { - let path = format!("{}/target/debug/", self.path(),); - let file = if cfg!(windows) { format!("{}.dll", self.name()) } else if cfg!(target_os = "macos") { @@ -35,7 +33,7 @@ impl Model { format!("lib{}.so", self.name()) }; - format!("{}{}", path, file) + format!("{}/target/debug/{}", self.path(), file) } pub fn load( From 5083ecc63c7580dcf7f7cea7d1b3fe6da1289361 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 28 Jan 2022 16:10:01 +0100 Subject: [PATCH 3/4] Refactor --- src/model.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/model.rs b/src/model.rs index d5d148f6d..bb982bdae 100644 --- a/src/model.rs +++ b/src/model.rs @@ -24,13 +24,15 @@ impl Model { } pub fn lib_path(&self) -> String { + let name = self.name(); + let file = if cfg!(windows) { - format!("{}.dll", self.name()) + format!("{}.dll", name) } else if cfg!(target_os = "macos") { - format!("lib{}.dylib", self.name()) + format!("lib{}.dylib", name) } else { //Unix - format!("lib{}.so", self.name()) + format!("lib{}.so", name) }; format!("{}/target/debug/{}", self.path(), file) From 5e0d5d7918bda6baa05752b0d11d29f8f4c6f237 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 28 Jan 2022 16:13:38 +0100 Subject: [PATCH 4/4] Fix model loading error, if name contains '-' --- src/model.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model.rs b/src/model.rs index bb982bdae..d8d8dca09 100644 --- a/src/model.rs +++ b/src/model.rs @@ -24,7 +24,7 @@ impl Model { } pub fn lib_path(&self) -> String { - let name = self.name(); + let name = self.name().replace("-", "_"); let file = if cfg!(windows) { format!("{}.dll", name)